I stumbled upon some examples of code and what I doesn't know is this x = y = z;
What does this code do?
Is this some kind of validation in javascript?
I stumbled upon some examples of code and what I doesn't know is this x = y = z;
What does this code do?
Is this some kind of validation in javascript?
It sets every variable to the value of the right-most expression. In this case, x
and y
will both get the value of z
.
It's an easy way to instantiate multiple variables, for example
for (var i = j = 0; i < 10; i++)
will give you a loop with 2 counters initialised - one that auto increments, and one that you can manually handle inside the loop.
No nothing like validation its simply assign value of z to y and y to x. so result is value of x , y and z are same.