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/array/of/index.html | 104 +++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 files/ko/web/javascript/reference/global_objects/array/of/index.html (limited to 'files/ko/web/javascript/reference/global_objects/array/of') diff --git a/files/ko/web/javascript/reference/global_objects/array/of/index.html b/files/ko/web/javascript/reference/global_objects/array/of/index.html new file mode 100644 index 0000000000..edcd9bddc5 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/array/of/index.html @@ -0,0 +1,104 @@ +--- +title: Array.of() +slug: Web/JavaScript/Reference/Global_Objects/Array/of +tags: + - Array + - ECMAScript 2015 + - JavaScript + - Method + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Array/of +--- +
{{JSRef}}
+ +

Array.of() 메서드는 인자의 수나 유형에 관계없이 가변 인자를 갖는 새 Array 인스턴스를 만듭니다.

+ +

Array.of()Array 생성자의 차이는 정수형 인자의 처리 방법에 있습니다. Array.of(7)은 하나의 요소 7을 가진 배열을 생성하지만 Array(7)length 속성이 7인 빈 배열을 생성합니다.

+ +
Array.of(7);       // [7]
+Array.of(1, 2, 3); // [1, 2, 3]
+
+Array(7);          // [ , , , , , , ]
+Array(1, 2, 3);    // [1, 2, 3]
+
+ +

구문

+ +
Array.of(element0[, element1[, ...[, elementN]]])
+ +

매개변수

+ +
+
elementN
+
배열을 생성할 때 사용할 요소.
+
+ +

반환 값

+ +

새로운 {{jsxref("Array")}} 객체.

+ +

설명

+ +

이 함수는 ECMAScript 2015 표준 일부입니다. 자세한 정보는 Array.of, Array.from 제안 사항Array.of 폴리필에서 확인하실 수 있습니다.

+ +

예제

+ +
Array.of(1);         // [1]
+Array.of(1, 2, 3);   // [1, 2, 3]
+Array.of(undefined); // [undefined]
+
+ +

폴리필

+ +

아래 코드를 다른 코드 이전에 포함하면 Array.of를 지원하지 않는 환경에서도 사용할 수 있습니다.

+ +
if (!Array.of) {
+  Array.of = function() {
+    return Array.prototype.slice.call(arguments);
+  };
+}
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES2015', '#sec-array.of', 'Array.of')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-array.of', 'Array.of')}}{{Spec2('ESDraft')}} 
+ +

 

+ +

 

+ +

 

+ +

브라우저 호환성

+ + + +

{{Compat("javascript.builtins.Array.of")}}

+ +

같이 보기

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