Check out the following code:
var numberArray = [0, 1]
(function() {
numberArray.push(2)
function nestedFunction() {
numberArray.push(3)
function anotherNestedFunction() {
numberArray.push(4)
}
console.log(numberArray)
}
})()
I anticipate numberArray
to have the values [0, 1, 2, 3, 4]
, however, an error is being thrown:
TypeError
:[0, 1]
is not a function