-4

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

Martin Tournoij
  • 24,971
  • 24
  • 101
  • 136
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
  • 824
  • 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
  • 77,877
  • 18
  • 158
  • 228
-1

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

("1"===1) = false
assert(false) => fail
ffflabs
  • 16,563
  • 5
  • 51
  • 75