ㅇㅇㅈ Blog

프론트엔드 수행중

0%

Object.is()

Object.is()

Object.is()는 인자로 받는 두 값이 같은지 확인해서 boolean으로 반환한다

구문

1
2
3
Object.is(value1, value2)

// true or false

예제

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Object.is('foo', 'foo');     // true
Object.is(window, window); // true

Object.is('foo', 'bar'); // false
Object.is([], []); // false

var test = { a: 1 };
Object.is(test, test); // true

Object.is(null, null); // true

// 특별한 경우
Object.is(0, -0); // false
Object.is(-0, -0); // true
Object.is(NaN, 0/0); // true

https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/is