开发者

Unattached anonymous functions and doubly named methods in javascript?

I'm debugging an app that uses .NET's scriptmanager.

It may be a glitch in firebug, but when I read through the code there are a lot of lines like the following:

// anonymous functions not attached as handlers and not called immediately
function () {
    //code
}

// named functions added as methods
myObj = {
    myMethod: function myFunctionName() {
        //code
    开发者_JAVA技巧}

}

Are these lines valid and, if so, what do they do and what possible reason would there be for coding like this (and I won't accept "It's microsoft - what d'you expect" as an answer)?


This might be worth a read: How does an anonymous function in JavaScript work?


They are there because some busy programmer was intending to do something and ran out of time, but left the stub as a reminder of work to be done. They do nothing as of yet.

or to watermark the code for checks that are done elsewhere in the logic

or simply put there to obfuscate...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜