From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- .../reference/global_objects/object/is/index.html | 124 +++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 files/ko/web/javascript/reference/global_objects/object/is/index.html (limited to 'files/ko/web/javascript/reference/global_objects/object/is') diff --git a/files/ko/web/javascript/reference/global_objects/object/is/index.html b/files/ko/web/javascript/reference/global_objects/object/is/index.html new file mode 100644 index 0000000000..2ead91a88a --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/object/is/index.html @@ -0,0 +1,124 @@ +--- +title: Object.is() +slug: Web/JavaScript/Reference/Global_Objects/Object/is +tags: + - ECMAScript 2015 + - JavaScript + - Method + - Object + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Object/is +--- +
{{JSRef}}
+ +

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

+ +

구문

+ +
Object.is(value1, value2);
+ +

매개변수

+ +
+
value1
+
비교할 첫 번째 값.
+
value2
+
비교할 두 번째 값.
+
+ +

반환 값

+ +

두 인수가 같은 값인지 여부를 나타내는 {{jsxref("Boolean")}}.

+ +

설명

+ +

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

+ + + +

이는 {{jsxref("Operators/Comparison_Operators", "==", "#Equality")}} 연산자에 따른 같음과 같지 않습니다. {{jsxref("Operators/Comparison_Operators", "==", "#Equality")}} 연산자는 같음을 테스트하기 전에 양 쪽(이 같은 형이 아니라면)에 다양한 강제(coercion)를 적용하지만("" == falsetrue가 되는 그런 행동을 초래), Object.is는 어느 값도 강제하지 않습니다.

+ +

이는 {{jsxref("Operators/Comparison_Operators", "===", "#Identity")}} 연산자에 따른 같음과도 같지 않습니다. {{jsxref("Operators/Comparison_Operators", "===", "#Identity")}} 연산자(와 {{jsxref("Operators/Comparison_Operators", "==", "#Equality")}} 연산자 역시)는 숫자값 -0+0을 같게 {{jsxref("Number.NaN")}}은 {{jsxref("NaN")}}과 같지 않게 여깁니다.

+ +

예제

+ +
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
+
+ +

폴리필

+ +
if (!Object.is) {
+  Object.is = function(x, y) {
+   // SameValue 알고리즘
+    if (x === y) { // Steps 1-5, 7-10
+     // Steps 6.b-6.e: +0 != -0
+      return x !== 0 || 1 / x === 1 / y;
+   } else {
+     // Step 6.a: NaN == NaN
+     return x !== x && y !== y;
+   }
+  };
+}
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('ES6', '#sec-object.is', 'Object.is')}}{{Spec2('ES6')}}초기 정의.
{{SpecName('ESDraft', '#sec-object.is', 'Object.is')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

{{Compat("javascript.builtins.Object.is")}}

+ +

같이 보기

+ + -- cgit v1.2.3-54-g00ecf