Reputation: 32883
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.
Upvotes: 0
Views: 118
Reputation: 45121
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));
http://jsfiddle.net/tarabyte/wf8ag/
Upvotes: 3
Reputation: 20043
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.
Upvotes: 0
Reputation: 16959
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...
demo: http://jsfiddle.net/jd3uM/
Upvotes: 4