I have something like the code below where I initialize an array in a "parent" function, then inside a "child" function I push a value to the array. But the array in the parent is not updated?And even inside the function I gather the value should be [1] but it is 1. Confused!Any idea what is going on?Thanksconst server = https.createServer(options, (req, res) => {let ids = []function addId() {ids.push(1)console.log(ids) //1, not [ 1 ] )}console.log(ids) // []})
Submitted October 23, 2018 at 06:20PM by snicksn
No comments:
Post a Comment