-4

Does JavaScript expression assert("1" === 1) gives PASS(TRUE) back ?

Martin Tournoij
  • 26,737
  • 24
  • 105
  • 146
user3697106
  • 61
  • 1
  • 2

3 Answers3

1

No, '===' means identical. "1" and 1 aren't identical because "1" is a string and 1 is a integer. Using '==' would return true.

Xanco
  • 874
  • 1
  • 10
  • 15
0

No it would return false.

The reason for this is because === is an equality check without coercion therefore the types are not converted. This means, effectively what you are comparing is a String to an Number which obviously aren't the same thing.

See Does it matter which equals operator (== vs ===) I use in JavaScript comparisons? for more info on the use of == vs ===.

Community
  • 1
  • 1
James
  • 80,725
  • 18
  • 167
  • 237
-1

String "1" is not === to integer 1, so you're evaluating assert(false) which returns fail.

("1"===1) = false
assert(false) => fail
ffflabs
  • 17,166
  • 5
  • 51
  • 77