How does JavaScript 'store' the s variable as an array? why wouldn't the s variable will be overwritten in this line"s.push(s[s.length - 1] + s[s.length - 2]); "
var number = prompt("fibonacci")
var fibo = function(n) {
if (n === 1) {
return [0, 1];
} else {
var s = fibo(n - 1);
s.push(s[s.length - 1] + s[s.length - 2]);
return s;
}
}
console.log(fibo(number));
BUT HOW IS IT STORING THE VARIABLE AS AN ARRAY?