Jump to content

L8V2L

Recommended Posts

Every thing is data... every thing.... data.... value.... everything is value.... variable....the units of JavaScript, JavaScript's value: string, number, undefined, Boolean, object, function(I don't they say arrays??? I'mma add arrays as one of the primitive value type of JavaScript's for there is an order for an array to be define, an syntax order.) and arrays.... everything...

 

I'm going to stop you right there. Before you run on with your own interpretation of types in Javascript, please review these docs.

http://msdn.microsoft.com/en-us/library/ie/7wkd9z69(v=vs.94).aspx

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Glossary

 

I would strongly suggest you familiarize yourself with concrete definitions of basic Javascript vocabulary and slowly your work your way to using those words instead of all the loose and vague associations you come up with.

Link to comment
Share on other sites

Okay so I can say it like this:var x = y;x assigned/assign y, as y is assigned/assign to x. <~~~~~~~ Right? Pay more attention to is for it, a least for me make the different in this. as you can say y you assign to me x, and as y can say, I'm assign to x, and as x could say y is assign to me, or better yet x assign y.... Right?

 

or simply

 

var x is equal to y

but yes, your understanding of it is correct.

Link to comment
Share on other sites

"Is equal to" can get a little vague in the technical details. I do read "x = y" as "x equals y", but assignment works differently based on the value. Scalar values will just get copied, but objects are assigned by reference until one of them is changed, and then the object gets copied and changed. It would be more technically correct to say that y is assigned to x, because that might mean that the value is copied or that x has a reference to y. Even though I read it as "equal to", it's technically not correct to say that. In pure terms, a reference to an object is not equal to that object.

Link to comment
Share on other sites

true, there is a distinction to what kind of assignment happens based on the type. That subtlety would account for a different interpretation then. Good point.

Link to comment
Share on other sites

"Is equal to" can get a little vague in the technical details. I do read "x = y" as "x equals y", but assignment works differently based on the value. Scalar values will just get copied, but objects are assigned by reference until one of them is changed, and then the object gets copied and changed. It would be more technically correct to say that y is assigned to x, because that might mean that the value is copied or that x has a reference to y. Even though I read it as "equal to", it's technically not correct to say that. In pure terms, a reference to an object is not equal to that object.

Yes me to justsomeguy, I agree, every time when I do read the equal sign, I read it as the definition put it so as it assign, or better yet as it's definition for the operator( = )meaning assign, or the assign operator. could you distinct the different, and mean of scalar values from values? You your post you said that scalar values just get copied... I'm... could you clarify please?

true, there is a distinction to what kind of assignment happens based on the type. That subtlety would account for a different interpretation then. Good point.

Any thescientist I (MONEKY AWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW MONKEY MONKEY MONKEY!!!!!!!! GIVE ME 413 NOW!!!! 413!!!! PIE!!!!!!!!! AAAAAWWWWWWWWWWWWWWWW)I can't read those Mozilla documentation as of now, as I am currently going through the Mozilla JavaScript guide documentation. Next I'll read through the reference hopefully and get to them slowly(as fast as I can while making sure I grasp the concept of what I'm reading, but I know I will have to go back to re-read them, which I'm actually planning on). For the documentation of http://msdn.microsoft.com/en-us/library/ie/7wkd9z69(v=vs.94).aspx I read the equivalent to it's counterpart it seem. Here: http://msdn.microsoft.com/en-us/library/7wkd9z69(v=vs.94).aspxBut I don't mind seeing to reading it all over on that site.For that post terms, they are coming to a online book that justsomeguy brought back to my attention, but I stop reading it as it jump from beginner to intermediate. here: http://eloquentjavascript.net/chapter2.html Edited by L8V2L
Link to comment
Share on other sites

I'm going to stop you right there. Before you run on with your own interpretation of types in Javascript, please review these docs.http://msdn.microsoft.com/en-us/library/ie/7wkd9z69(v=vs.94).aspxhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Referencehttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Glossary I would strongly suggest you familiarize yourself with concrete definitions of basic Javascript vocabulary and slowly your work your way to using those words instead of all the loose and vague associations you come up with.

I went ahead and read: http://msdn.microsoft.com/en-us/library/ie/7wkd9z69(v=vs.94).aspxthe rest will come as in passing while I read through the JavaScript guide.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Another~~~post~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I say everything is a reference of an object that is intrinsic in JavaScript. You don't make nothing, you just composite items that already their in an arrangement that is following the rules of JavaScript. As with lego, you can't put to lego blocks next two each other hoping they will stick, You most stack them on top of each other, but with JavaScript it's the other way, you must build underneath your code, from top to bottom. Edited by L8V2L
Link to comment
Share on other sites

Defining getters and settersA getter is a method that gets the value of a specific property. A setter is a method that sets the value of a specific property. You can define getters and setters on any predefined core object or user-defined object that supports the addition of new properties. The syntax for defining getters and setters uses the object literal syntax.JavaScript 1.8.1 noteStarting in JavaScript 1.8.1, setters are no longer called when setting properties in object and array initializers.The following JS shell session illustrates how getters and setters could work for a user-defined object o.They use a JS shell(which I have no ideal what that is) to illustrate this, could someone please provide me a detail explanation for these two?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Another~~~post~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~In JavaScript, there are three primary data types, two composite data types, and two special data types.--------------------------------------------------------------------------------The primary (primitive) data types are:•String•Number•Boolean--------------------------------------------------------------------------------The composite (reference) data types are:•Object•Array---------------------------------------------------------------------------------The special data types are:•Null•Undefined----------------------------------------------------------------------------------Where's function? ... in my opinion function are composite.-----------------------------------another post-----------------------------------var y = 43;delete y; // returns false (cannot delete if declared with var)This is not true! Is it? I asks JavaScript's Interpreter and it said no!

Edited by L8V2L
Link to comment
Share on other sites

could you distinct the different, and mean of scalar values from values?

Scalar values are the 3 primitive types listed in the Microsoft article.

I say everything is a reference of an object that is intrinsic in JavaScript.

The word "reference" has a special meaning in programming. In Javascript, some things are references to objects, other things are actual objects. It's not a philosophical difference or opinion, it's what technically happens.
var d = new Date(); // d is a Date objectvar e = d; // e is a reference to an objecte.setDate(10); // e is changed// even though only the e variable was changed, both variables show the same value because e is a reference to dconsole.log(d);console.log(e);var a = 10; // a is set to a scalar valuevar b = a; // the value of a is copied to bb++; // b is changedconsole.log(a); // a stays the same because b is not a reference to aconsole.log(B); // b is different
I was wrong about this:

objects are assigned by reference until one of them is changed, and then the object gets copied and changed

They use a JS shell(which I have no ideal what that is) to illustrate this, could someone please provide me a detail explanation for these two?

Where did that come from? Do you know what object properties are?

in my opinion function are composite.

The computer doesn't care what your opinion is. A function is a kind of object. Like I said, nearly everything in Javascript is an object.

This is not true! Is it? I asks JavaScript's Interpreter and it said no!

Yes, delete only works on object properties, not local variables. When you create a global variable, it is actually a property of the window object, so it can be deleted. Local variables in functions cannot be deleted. Compare what happens when you run these two, one of them creates a global variable which is a property of the window object, and the other creates a local variable inside an anonymous function:
var y = 43;console.log(this);console.log(this.y);console.log(delete y);console.log(y);
(function() {var y = 43;console.log(this);console.log(this.y);console.log(delete y);console.log(y);})();
There's a discussion about the delete operator here:http://perfectionkills.com/understanding-delete/
  • Like 1
Link to comment
Share on other sites

Scalar values are the 3 primitive types listed in the Microsoft article.[quota]Number, string, Boolean?[quota]The word "reference" has a special meaning in programming. In Javascript, some things are references to objects, other things are actual objects. It's not a philosophical difference or opinion, it's what technically happens.

var d = new Date(); // d is a Date objectvar e = d; // e is a reference to an objecte.setDate(10); // e is changed// even though only the e variable was changed, both variables show the same value because e is a reference to dconsole.log(d);console.log(e);var a = 10; // a is set to a scalar valuevar b = a; // the value of a is copied to bb++; // b is changedconsole.log(a); // a stays the same because b is not a reference to aconsole.log(; // b is different
[quota]Could you give me another explain of this? I understand it, but maybe a list of objects code like[quota]I was wrong about this:[/quota]Wrong about what?[quota]Where did that come from? Do you know what object properties are?[/quota]In the JavaScript guide on mdn I'm it explain getter and setter using spidermonkey jsshell, which I have no ideal what it is, and don't feel like detouring and getting off track to find out(read my signature that will refer you to my pic). So I ask could you explain getter and setter.[quota]The computer doesn't care what your opinion is. A function is a kind of object. Like I said, nearly everything in Javascript is an object.[/quota]What I was asking is, what data type is function? Shouldn't it be composite? I know everything is an object(everything have a prototype object to reference to.) but what type of data do function belong to? It should be composite right? And I'm talking about referencing from the page I got the information from. Please reply according to that.[quota]Yes, delete only works on object properties, not local variables. When you create a global variable, it is actually a property of the window object, so it can be deleted. Local variables in functions cannot be deleted. Compare what happens when you run these two, one of them creates a global variable which is a property of the window object, and the other creates a local variable inside an anonymous function:
var y = 43;console.log(this);console.log(this.y);console.log(delete y);console.log(y);
(function() {var y = 43;console.log(this);console.log(this.y);console.log(delete y);console.log(y);})();
There's a discussion about the delete operator here:http://perfectionkills.com/understanding-delete/

 

Appreciate the link, but I wish not to detour unless it's in the page which direct me to know other links, that way it's safe for my mind to wonder all over the page, and I can progress somewhat smoothly with out worrying about going off track(even know I am, but on the page that I'm trying to read, so in away it's okay.) If I remember, and feel put towards, I'll go back to it.
Link to comment
Share on other sites

I think I get it, you must define a variable be for you can use it, you don't need the var keyword, but that variable need to be define as something. Just having x and nothing defining it will cause x to be undefined. but having var x; or x = 5; is defining it. As the keyword var defined it as being a variable, and the x with out the key word but with the assignment sign define it as being what ever is on the right of the assignment sign.Me: JavaScript?JavaScript: Yes my son.Me: I put in type of(me); but the interpreter, your son, said undefined. What does that mean?JavaScript: It mean, you as an existence being can not be label as one of any word. Your infinite inscribed, so in other word, you can not be defined as one label.Me: Oh.JavaScript: Don't you have studying to do?Me: Oh, yes.JavaScript: then go on my son, expand your mind.Me: Yes, JavaScript. I will.

Edited by L8V2L
Link to comment
Share on other sites

As the keyword var defined it as being a variable, and the x with out the key word but with the assignment sign define it as being what ever is on the right of the assignment sign.

It's still a variable with or without the var keyword. The difference is the scope in which the variable gets defined. Variables defined using var are defined as local to the scope they are in.
Link to comment
Share on other sites

If you know that none of the elements in your array evaluate to false in a boolean context — if your array consists only of DOM nodes, for example, you can use a more efficient idiom:

// Could someone implement this: colors = ['red', 'white', 'blue']; // into this:var divs = document.getElementsByTagName('div');for (var i = 0, div; div = divs[i]; i++) {  /* Process div in some way */}
This avoids the overhead of checking the length of the array, and ensures that the div variable is reassigned to the current item each time around the loop for added convenience.And explain what they are conveying to me?
Link to comment
Share on other sites

◦if a is less than b by the sorting system, return -1 (or any negative number)◦if a is greater than b by the sorting system, return 1 (or any positive number)◦if a and b are considered equivalent, return 0.For instance, the following will sort by the last letter of an array:

var sortFn = function(a, {  if (a[a.length - 1] < b[b.length - 1]) return -1;  if (a[a.length - 1] > b[b.length - 1]) return 1;  if (a[a.length - 1] == b[b.length - 1]) return 0;}myArray.sort(sortFn); // sorts the array so that myArray = ["Wind","Fire","Rain"]
WHAT!!!!!!!????????? Edited by L8V2L
Link to comment
Share on other sites

[0,1,2,3,4].reduce(function(previousValue, currentValue, index, array){return previousValue + currentValue;});
The callback would be invoked four times, with the arguments and return values in each call being as follows:1st call: previousValue = 0 currentValue = 1 return 12nd call: previouValue = 1 currentValue = 2 return 33rd call: previousValue = 3 currentValue = 3 return 64th call: previousValue = 6 currentValue = 4 return 10I think it get it... It's just crazy.SO if I understand, than this should be right:
var arr = [5, 6, 7, 8, 9];arr.reduce(function(previousValue, currentValue){console.log(previousValue + currentValue)};
1st call: previousValue = 5 currentValue = 6 return 112nd call: previousValue = 11 currentValue = 7 return 183rd call: previousValue = 18 currentValue = 8 return 264th call: previousValue = 26 currentValue = 9 return 35Okay, now that I work that out(In my head mind you), let's ask the interpreter!Yes the output return 35 in the console.But not at first, I had to change something's.first I was missing syntax, and after trial and error. I correct it:
var arr = [5, 6, 7, 8, 9];arr.reduce(function(previousValue, currentValue){console.log(previousValue + currentValue);});
or a least an output which return: 11, NaN, NaN, NaN. SO I look at the... I guest I can call it a framework... right? Or better yet just explain(someone please explain a framework in great entertaining details please!!!!! 431=PIE) SO I say it had return instead in console.log after inspecting it. So than I change it:
arr.reduce(function(previousValue, currentValue){return(previousValue + currentValue);});
which gave me 35 in red... But I wanted it in black!!!! PIE = 431!!!!! So...
var a=arr.reduce(function(previousValue, currentValue){return(previousValue + currentValue);});console.log(a);
OUTPUT IN BLACK! YEAH!!!!! $#!=PIE!!!!Me: JavaScript?JavaScript: yes my son?Me: I love you.JavaScript: And so do I. Now aren't you forgetting something?Me: Oh!Could you please explain to me in detail why is this call reduce, and how is this reducing the array, unless they are talking about the length. I please explain!!!! $#! = 431 = PIE = pie!!!!Me: Thank you JavaScript.JavaScript: Your welcome my son. Now go and continue to expand your young novice mind.Me: Yes JavaScript. I will. Edited by L8V2L
Link to comment
Share on other sites

Scalar values are the 3 primitive types listed in the Microsoft article.The word "reference" has a special meaning in programming. In Javascript, some things are references to objects, other things are actual objects. It's not a philosophical difference or opinion, it's what technically happens.

var d = new Date(); // d is a Date objectvar e = d; // e is a reference to an objecte.setDate(10); // e is changed// even though only the e variable was changed, both variables show the same value because e is a reference to dconsole.log(d);console.log(e);var a = 10; // a is set to a scalar valuevar b = a; // the value of a is copied to bb++; // b is changedconsole.log(a); // a stays the same because b is not a reference to aconsole.log(; // b is different

 

It seem to me if it is a primitive value, then it'll just get copy, else if it otherwise; such as object, method, or and function they'll get reference.
'it seem to be if it is a primitive value,' ? 'then it'll be copy,' : 'else if other, it'll get reference';  
Edited by L8V2L
Link to comment
Share on other sites

why do the syntax look like this:

if (condition)  statement_1[else  statement_2]//and not like this:if (condition)  satement_1else  satement_2
What's the meaning of the []?It may not seem like a important question, but to understand the fact that one is looking for knowledge at the smallest detail, than just going off of consumption... well, if you can please answer.
Link to comment
Share on other sites

In the codes above, the name variable of the outer function is accessible to the inner functions, and there is no other way to access the inner variables except through the inner functions. The inner variables of the inner function act as safe stores for the inner functions. They hold "persistent", yet secure, data for the inner functions to work with. The functions do not even have to be assigned to a variable, or have a name.I see it as the inner functions act as a safe stores for the inner variables, than it being said above. This may not be a question, but it more important then that. this is speaking the concept to which one must grasp in order to completely understand JavaScript.my second argument is that the author made an typo for this is similar to writing a tongue twister... to me that is.

Link to comment
Share on other sites

This avoids the overhead of checking the length of the array, and ensures that the div variable is reassigned to the current item each time around the loop for added convenience.

They are showing a more efficient for loop that will work in certain situations, in the situations where none of the array elements will evaluate to false. It would not work for this array, because 0 would evaluate to false:
var ar = [1, 8, 4, 0, 9, 3];
But it will work for any array where you can guarantee that none of the values will evaluate to false. The example they give is an array of DOM nodes. A DOM node will never evaluate to false. This is the loop they give:
for (var i = 0, div; div = divs[i]; i++) {
The 3 parts of a for loop are the initializers, the finish condition, and the iteration. The finish condition says div = div. You can use that in an if statement also:
if (div = divs[i])
The reason why those things are legal is because when it needs to evaluate an assignment expression like that to a true/false value, it does the assignment first, and then it evaluates the left-hand value (the value inside div) to see if it will evaluate to true or false. Values that will evaluate to false include things like 0, the empty string, the value undefined, etc. If divs is an array of DOM nodes (or anything else), and you try to access an element that doesn't exist (if i is bigger than the length of the array), then div will be set to undefined, it will evaluate to false, and the loop will end. The reason that is more efficient is because it does not need to check the array's length property every time through the loop. This is the alternative that has to check the length every time:
for (var i = 0, div; i < divs.length; i++) {  div = divs[i];  ...

WHAT!!!!!!!?????????

Just like it says:

For instance, the following will sort by the last letter of an array:

  • Like 1
Link to comment
Share on other sites

Thanks justsomeguy for the explanation above.

var a = [10, 20, 30];var total = a.reduceRight(function(first, first) { return first + first; });console.log(total); // log 20 Why? I know it have something to do with the nming being    //the same, but the math ouput should not be 20.... How?    //I look at the reference page they had, and it seem to do what I expect it do.
Edited by L8V2L
Link to comment
Share on other sites

It returns 20 because, apparently, in Javascript when you have a function where the parameters have the same name, the value of that variable is the value of the last parameter. I'm just guessing based on your results, because I've never tried to see what happens if you give all of the parameters the same name. Doing that doesn't make sense to me, there's no use for it.Your function gets called with these parameters:30, 20 -> return 40 (20 + 20)40, 10 -> return 20 (10 + 10)

  • Like 1
Link to comment
Share on other sites

It returns 20 because, apparently, in Javascript when you have a function where the parameters have the same name, the value of that variable is the value of the last parameter. I'm just guessing based on your results, because I've never tried to see what happens if you give all of the parameters the same name. Doing that doesn't make sense to me, there's no use for it.Your function gets called with these parameters:30, 20 -> return 40 (20 + 20)40, 10 -> return 20 (10 + 10)

Yes, it seem that way. Doing it with the method reduce produce.
10, 20->40 [20+20]40, 30->60 [30+30]
Thanks for the clarity. Edited by L8V2L
Link to comment
Share on other sites

Do you want us to assign you a problem to solve? Create some sort of form with appropriate validation code.

Could you do that again please... But with question, basic question... Foundational JavaScript... sorry if I didn't show the appreciation toward the value of your action, but I need question that I can read and answer, for I'm going through tutorials to try to advance and strength the foundation I'm setting for myself. Such question as what is this, what does this function do, what is this function missing, what is the syntax for a literal array, what is the two ways beside literal to make an array, what is the three ways beside literal to make a function, etc. Could you do such post as this? Please... Could you considerate it... and anyone else who is reading this. Thank you, to those who took the time to read this.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...