Object API: Object.is()
Object.is()
compares if two values are the same.
Donate to NGO Julenka. Support Ukranians in need.
Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.
Object.is()
determines whether two values are the same
scalar values
- 1 is the same as 1
- int 1 is different to string "1"
- strings just have to match
- +0 is not the same as -0
- NaN is the same as NaN
coercion (as in ==
) and strict compare (as in ===
) do NOT apply
- +0 and -0 are not the same for
Object.is()
- empty string and
false
are not the same
- NaN
- NaN and 0/0
complex values
{}
is just not the same as {}
- for the same object
is()
reports true
- two
Map
s with the same content are not the same thing