Friday, September 2, 2022

JavaScript destructuring assignment

 

var foo = ['one', 'two', 'three'];

undefined

var [one,two,three] = foo;

undefined

one;

'one'

one = 'one1';

'one1'

foo;

(3) ['one', 'two', 'three']

foo[1] == two;

true

foo[1] === two;

true

foo[0] == one;

false

I used that investigation to understand the purport of the assignment, see the conclusion is that isn't one per 100 by one per 100, is that if I change the value of the free variable this would not make any change to the variable dependent of the array so one if changed that will not change the foo[0]. Is like what hurt you hurt me but what hurt me doesn't hurt you, where is the perfect love? So the array isn't where I want went just the way the final of the road is the free variable. Rute Bezerra de Menezes Gondim





No comments:

Post a Comment