I'm using Visual Studio 2015 and try to update all updates which it needs.
My problem: when I create a new js file, the js compiler would gave me an error eqeqeq
(I don't understand what this code means) whenever I use '=='
to compare.
Example:
// Declaring a number within a default value
var caret_index = 0;
// Now, js compiler should know 'caret_index' type
// alert(typeof(caret_index)); -> number
// alert($.type(caret_index)); -> number
// So,
// Expected '===' and instead of saw '=='
if (caret_index == 0) {
// ...
}
That said: You must use '===' in the
if condition.
Why? It just needn't cast caret_index
to number
before comparing to 0
.
It's not Visual Studio, it's your lint settings. If you don't have a .eslintrc.json
file in your project root, then create it. Visual Studio will read this to see which rules it should apply. Look for the triple equals rule:
"triple-equals": [
false,
"allow-null-check"
]
alternatively, it might be a rule contained in an external file if you have any references under rules directory:
"rulesDirectory" :[]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.