有时我会在网络教程中看到这一点:
/**
* 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 );
}
谁能告诉我这个括号是做什么用的吗?
最佳答案
由于 return
是一个语句,而不是一个方法,因此不需要括号。
关于javascript - 在返回变量中使用括号的优点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22332749/