开发者

javascript to jquery conversions

开发者 https://www.devze.com 2023-02-13 15:59 出处:网络
I have a JavaScript function which returns a function. What does it mean ? function CheckShadowBounds(rounded) {

I have a JavaScript function which returns a function. What does it mean ?

function CheckShadowBounds(rounded) {
    return function() {
    };
}
开发者_JAVA百科

How can I convert it to jQuery ?


It means it returns a function. Functions are first class objects and can be passed around just like strings, arrays, etc, etc.

The purpose of this example is to define rounded for the function. The same instance of rounded will be used every time the returned function is called.

You can't convert it to jQuery. jQuery is a set of predefined JavaScript functions that do things lots of people want to do, but which are relatively complex (often because of browser incompatibilities). This is not something that is relatively complex, so jQuery doesn't provide a helper function.


See Joel Spoelsky's intro to functional programming in JS to understand some ways a function returning a function can be useful: http://www.joelonsoftware.com/items/2006/08/01.html

This shouldn't need any changes to work in JQuery.

0

精彩评论

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

关注公众号