2017-02-07 39 views
0

我学习的平均堆,当我建立的MongoDB我与猫鼬我用这个:'err'是错误的保留字吗?

mongoose.connect(mongooseUrl, function(err){ 
if(err){ 
    console.log('There\'s been an error'); 
    console.log(err); 
} else { 
    console.log('Connected to '+ mongooseUrl + '!'); 
} 

我只是想知道,如果“犯错”是在JS错误的保留关键字。

谢谢!

+1

保留字是[* ECMA-262 *](HTTP完全任意名称:// ECMA -international.org/ecma-262/7.0/index.html#sec-reserved-words),尽管令人讨厌的是它们没有按字母顺序排列。 “err”不是其中之一。 – RobG

+0

@RobG为什么它会返回'the'错误? –

回答

2

不,它不是...这是你自己分配到的参数列表中的第一个函数参数

+0

为什么它会返回'the'错误? –

+2

这是第一个错误参数函数的node.js作为回调函数使用的异步回调的标准约定(本身采用[continuation-passing style](https://en.wikipedia.org/wiki/Continuation- passing_style))。您可以在这里阅读更多关于它的信息 - > http://callbackhell.com/ –

+0

感谢您的链接,我很难与回调函数。 –