1

In JS, I understand the difference between the non-strict equality operator == and the strict equality operator === and how they evaluate different expressions differently, for example 0 == false but 0 !== false. However, their names, "strict" and "non-strict" have led me to question their evaluations in strict mode. For example, if I had the following code:

// some code ...

function name(parameters) {
  'use strict';

  // my question is, within this strict evaluated function, will '==' evaluate as '==='?

  if (parameters == '') {
    throw new Error(`Expected a valid value for parameters, but got ${parameters}`);
  }
}

Because this is in strict mode, if I pass 0 into parameters, will it throw the error because 0 == '', or will it evaluate it as 0 === '', which would return false? This is just an example to illustrate my question (in the title).

My guess is that the answer is no, but it is possible that strict mode will evaluate everything strictly, including these equality operators.

Also, is there any documentation that will show this?

applemonkey496
  • 683
  • 1
  • 10
  • 29

0 Answers0