S
S
Sirion2018-02-08 14:04:11
JavaScript
Sirion, 2018-02-08 14:04:11

Is there a case where "==" is better than "==="?

I will clarify: a practically significant case. It is easy to artificially set a task in which "==" will be more concise, but I am interested in exactly something that will benefit the national economy.
PS Saving one character is not taken into account.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Michael, 2018-02-08
@Sirion

I use only for:

if (a == null) {
// код
}

in this case, it doesn't matter if we have undefined in 'a' or null, while for any 0, false, etc. condition will be false

D
Dmitry Kim, 2018-02-08
@kimono

if ($('input').val() == false) alert('Введите непустое значение'); // not null, 0, ''

V
VoidVolker, 2018-02-08
@VoidVolker

shamansir.github.io/JavaScript-Garden/ru/#types

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question