I want to alert is it executed well? after following line is executed in javascript
window["is"]("it")("executed")("well")("?")
window here means a global object. I have no idea what that above line is in javascript.
I want to alert is it executed well? after following line is executed in javascript
window["is"]("it")("executed")("well")("?")
window here means a global object. I have no idea what that above line is in javascript.
window.is = function(it){
return function(executed){
return function(well){
return function(questionMark){
alert("is "+it+" "+executed+" "+well+" "+questionMark);
}
}
}
}
window["is"]("it")("executed")("well")("?")
strange question. there's probably a more efficient way of doing it...
is as a string when defining the function. But yeah, this is a super weird question.window.is Is a function that returns a function that returns a function that returns a function. These functions all accept parameters, which are being concatenated in the "deepest" function. Still following? No? That's why window["is"]("it")("executed")("well")("?") is a bad idea.Evil recursion :)
arguments.callee refers to the function you are currently calling.
window.is = (function(len){
var buffer = ["is"];
return function(str) {
buffer.push(str);
if(buffer.length === len) {
alert(buffer.join(" "));
}
else {
return arguments.callee;
}
}
}(5));
The following works, although I can't think of any possible use for something that ugly.
window["is"] = function (it) {
return function (executed) {
return function (well) {
return function (questionMark) {
alert("is " + it + " " + executed + " " + well + questionMark);
}
}
}
}
The first thing is to add the is element to the window array (oh my…) and then keep returning functions that will be called.