Hi Guys
I am running JSLint for validation, and I am finding that it is throwing an error on the third function in a commonJS module. For example:
function EmptyWindow() { ... } EmptyWindow.prototype.foo1 = function () { .... } EmptyWindow.prototype.foo2 = function () { .... }in this case, JSLint throws an "Unexpected 'EmptyWindow' error for foo2. If I change foo2 to be something else, say
Object.defineProperty( EmptyWindow, 'THIS_IS_A_VALUE', {value:0, enumerable: true} );then I get the error "Unexpected 'Object'. This is consistent over my entire code base.
I am using Titanium Studio, build: 2.1.2.201208301612
2 Answers
Accepted Answer
Ok, so, yea man, you're not closing your variable functions:
function EmptyWindow() {} EmptyWindow.prototype.foo1 = function () { }; EmptyWindow.prototype.foo2 = function () { };
I encourage you to use K&R style indentation and line breaking with your JavaScript code. See Titanium Coding styles and conventions or Google's coding conventions pages for more info. Also keep in mind that statements should end with a semicolon. Failure to do so can result in "hard to debug" problems. See Google's page on semi-colons
// this is an assignment statement: EmptyWindow.prototype.foo1 = function () { .... } // and should end with a semicolon // better to be written as: EmptyWindow.prototype.foo1 = function () { .... };
Your Answer
Think you can help? Login to answer this question!