This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Object.is()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015년 9월⁩.

Object.is() 정적 메서드는 두 값이 같은 값인지 결정합니다.

시도해 보기

console.log(Object.is("1", 1));
// Expected output: false

console.log(Object.is(NaN, NaN));
// Expected output: true

console.log(Object.is(-0, 0));
// Expected output: false

const obj = {};
console.log(Object.is(obj, {}));
// Expected output: false

구문

js
Object.is(value1, value2);

매개변수

value1

비교할 첫 번째 값.

value2

비교할 두 번째 값.

반환 값

두 인수가 같은 값인지 여부를 나타내는 불리언.

설명

Object.is()는 두 값이 같은 값인지 결정합니다. 다음 중 하나를 만족하면 두 값은 같습니다.