O
O
Oleg Torbasov2015-11-28 15:32:31
JavaScript
Oleg Torbasov, 2015-11-28 15:32:31

How to make Javascript more strict?

Javascript, without the slightest indignation, swallows such constructions, for example:

if(…){
this.value===value;//вместо =
}
someObject[undefined]=value;//создаёт текстовый ключ "undefined"
let x=1/0;

How can I make it throw, if not Error, then at least warning? Strict mode doesn't help in these cases, and in many others. Maybe there is a Firefox add-on or code analyzers?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alecxandrys, 2015-11-28
@Alecxandrys

As an option
Or any other implementation of JSHint.
Depending on the settings, the IDE can highlight such things for you.

D
Dmitry Belyaev, 2015-11-28
@bingo347

Learn to write normally, all of the listed options are absolutely correct from the point of view of javascript and can be used
this.value===value; - quite a normal expression, it even has a result - true or false, it is clear that in such use it does not carry a load
someObject[undefined]=value; - although this is obvious shit code, nevertheless String(undefined) === 'undefined'
let x=1/0; - x will be equal to Infinity

N
Nicholas, 2015-11-28
@ACCNCC

The flexibility of JS is a huge plus! Just write normal code)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question