dimanche 15 mars 2020

Shortened if statements and their direct equivalents in JavaScript

I've been studying JavaScript for a couple months, and I have some questions.

Say we have some if statements like this:

if (something)

if (!something)

From what I have looked up, the first statement checks whether something evaluates to true, whereas the second one checks for whether the condition is not true(I recall reading the ! coerces it into boolean and then 'inverses' it).

However, I'd like to know what are these statements' direct equivalents when not "shortened". I'd like to understand code like this more in depth before really using it.

Is if (something) the same as if (something == true)? Or even if (something === true)?

And what would be the "non-shortened" (for my lack of a better term) direct equivalent of if (!something)?

Thank you for any help.

Aucun commentaire:

Enregistrer un commentaire