在返回变量中使用括号的优点

时间:2014-03-11 17:54:30

标签: javascript

有时我会在网络教程中看到这一点:

/**
 * Just for example
 */
function getConstructor() {

    /**
     * Constructor fn, that will be returned by 'getConstructor' fn
     */
    function SomeTypeConstructor() {
        // some code
    }

    //////////////////////////////////////////////////
    // And here is the question!
    // What is this parentheses for?
    return( SomeTypeConstructor );
}

有谁可以说这个括号是什么?

1 个答案:

答案 0 :(得分:0)

由于return是一个语句而不是方法,因此不需要括号。