I'm trying to run this simple code in my node+express code
mongoose.model('Package').find(query, function(err, package) {.....
and it fails with
mongoose.model('Package').find(query, function(err, package) {.....
^^^^^^
and I don't know why. It works if I change the variable name from "package" to something else.
There is too much code to copy paste here, but I guess this must be something rather basic I'm doing wrong since a variable name change solves it. What could the problem be?
You can't use word
package
in JavaScript, because it's a reserved word.You'll find the full list of reserved words on w3schools.com site and on Mozilla Developer Network site.
According to Mozilla Developer Network site, word
package
is reserved as future keywords by the ECMAScript specification. It means thatpackage
keyword have no special functionality at present, but it might at some future time, so it cannot be used as identifier of any kind (e.g. as variable, label, or function name).