Note: This is mostly a theoretical practice.
function one() {
return [1, function() { one(); }];
}
console.log((one()[1])());
The output gives undefined
. Why?
Note: This is mostly a theoretical practice.
function one() {
return [1, function() { one(); }];
}
console.log((one()[1])());
The output gives undefined
. Why?
拆分它:
function one() {
return [1, function() { one(); }];
}
console.log((one()[1])());
one(); // [1, function() { one(); }]
[1] // function() { one(); }
() // undefined
如果您返回one()
,它将返回数组:
function one() {
return [1, function() { return one(); }];
}
console.log((one()[1])());
one(); // [1, function() { return one(); }]
[1] // function() { return one(); }
() // [1, function() { return one(); }]