Reputation: 10838
I have pretty simple JS
function () { //**Expected identifier** over first bracket
window.Root = {
Models : {},
Views : {},
Comments : {}
}
}
.call(this) //**Syntax error** over dot
But getting an errors
function () - Expected identifier
. call(this) - Syntax error
Could some one explain why that errors talking place and how to fix that?
Upvotes: 0
Views: 55
Reputation: 16020
You've forgotten the parentheses:
(function () {
window.Root = {
Models: {},
Views: {},
Comments: {}
}
}).call(this);
Because expressions cannot start with function
or {
, it is treated as a declaration and therefore fails. Function declarations must have an identifier, and since .call
is completely separate from the function declaration, it is therefore a syntax error (as .call(this)
in itself is not a valid statement).
Upvotes: 2
Reputation: 5947
You have missed the paranthesis in your function.
(function () { //**Expected identifier** over first bracket
window.Root = {
Models : {},
Views : {},
Comments : {}
}
});
.call(this) //**Syntax error** over dot
Upvotes: 0