+ 1
Why this code result is 4? b was defined before array a change
3 odpowiedzi
+ 5
Because arrays are objects.
console.log(typeof [1,2,3])
-->object
Variables get "references" to objects (not copies).
Assigning a variable to another variable that points to an object just creates two pointers to the SAME object, not two full objects.
Primitive types / not objects are stored as values (and make copies):
a=3
b=a // gets a copy
a=0 // b is not affected
console.log(a + "," + b)
0,3
+ 1
Kirk, thank you
0
I cant understand your question but my ans is
a=3;
b=a //means b=3
a=0 //means now a=0 but not a=3
so that's why a=0 and
b=3
console.log(a+"."+b)//a=0 and b=3 so 0.3 ans.
here you mention point in peremiter(eg a+"."+b), if you write like (a+" "+b) then you will get 0 3.
I hope your meaning is clear...