[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/join [Back]  [Original]

Array.prototype.join() - JavaScript | MDN

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

Array.prototype.join()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.

Array Join() . , .

In this article

const elements = ["Fire", "Air", "Water"];

console.log(elements.join());
// Expected output: "Fire,Air,Water"

console.log(elements.join(""));
// Expected output: "FireAirWater"

console.log(elements.join("-"));
// Expected output: "Fire-Air-Water"

js
join()
join(separator)

separator Optional

. (",") .

. arr.length 0, .

. undefined, null , "null" "undefine" .

Array.prototype.toString() join . join toString .

Array.prototype.join . Array.prototype.toString(join() ) . , .

js
const matrix = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9],
];

console.log(matrix.join()); // 1,2,3,4,5,6,7,8,9
console.log(matrix.join(";")); // 1,2,3;4,5,6;7,8,9

( ) , .

js
const arr = [];
arr.push(1, [3, arr, 4], 2);
console.log(arr.join(";")); // 1;3,,4;2

, join() undefined .

join() . this length .

a , , , .

js
const a = ["", "", ""];
a.join(); // ',,'
a.join(", "); // ', , '
a.join(" + "); // ' +  + '
a.join(""); // ''

join()

join() undefined .

js
console.log([1, , 3].join()); // '1,,3'
console.log([1, undefined, 3].join()); // '1,,3'

join()

join this length length .

js
const arrayLike = {
  length: 3,
  0: 2,
  1: 3,
  2: 4,
  3: 5, // length 3  join() .
};
console.log(Array.prototype.join.call(arrayLike));
// 2,3,4
console.log(Array.prototype.join.call(arrayLike, "."));
// 2.3.4

Specification
ECMAScript 2027 LanguageSpecification
# sec-array.prototype.join


Web Proxy Viewer  |  New URL  |  Original Page