Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does JSLint give strict violation error on this function?

JSLint gives me the "strict violation" error, although I use the "this" context inside a function which hides it from the global scope.

function test() {
    "use strict";
    this.a = "b";
}

For the record, I use the built-in JSLint parser in Webstorm.

like image 272
Erik Bergstedt Avatar asked Jul 21 '13 07:07

Erik Bergstedt


1 Answers

This is because JSLint doesn't recognize your function as a constructor. By convention, you must use uppercase letters.

function Test() {
    "use strict";
    this.a = "b";
}
like image 91
Erik Bergstedt Avatar answered Sep 22 '22 01:09

Erik Bergstedt