'Why array is not updated in this example, strange? [closed]
Output should be [2,3,5,9] for both a and b as per me, as they both point to same address, and the data has a push of 9. Why the result is still the old data of [2,3,5]?
var a = [2,3,5];
var b = a;
b.push[9];
console.log(a, b);
Solution 1:[1]
Wrong brackets you need to do b.push(9)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Paul |
