为什么在JavaScript中返回时使用括号? [英] Why use parentheses when returning in JavaScript?
本文介绍了为什么在JavaScript中返回时使用括号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Restify框架代码中我找到了这个函数:
In the Restify framework code I found this function:
function queryParser(options) {
function parseQueryString(req, res, next) {
// Some code goes there
return (next());
}
return (parseQueryString);
}
为什么作者会写 return(next() );
和 return(parseQueryString);
?它是否需要括号,如果是,为什么?
Why would the author write return (next());
and return (parseQueryString);
? Does it need parentheses there and if so, why?
推荐答案
它不需要那样,但它是有效的JavaScript码。实际上,看到这样的语法并不常见。我想这是作者的个人偏好。
It doesn't need to be that way, but it's valid JavaScript code. Actually it's quite uncommon to see such syntax. I guess it's a personal preference of the author.
这篇关于为什么在JavaScript中返回时使用括号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文