Note: This is mostly a theoretical practice.
function one() {
return [1, function() { one(); }];
}
console.log((one()[1])());
The output gives undefined
. Why?
To split it up:
function one() {
return [1, function() { one(); }];
}
console.log((one()[1])());
one(); // [1, function() { one(); }]
[1] // function() { one(); }
() // undefined
If you return one()
it will return the array:
function one() {
return [1, function() { return one(); }];
}
console.log((one()[1])());
one(); // [1, function() { return one(); }]
[1] // function() { return one(); }
() // [1, function() { return one(); }]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With