[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/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 ..

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"

arr.join([separator])

separator

, . . , ','. - , .

, . arr.length == 0, .

. undefined null .

a , : , , , , .

js
var a = ["", "", ""];
var myVar1 = a.join(); //  ',,'  myVar1
var myVar2 = a.join(", "); //  ', , '  myVar2
var myVar3 = a.join(" + "); //  ' +  + '  myVar3
var myVar4 = a.join(""); //  ''  myVar4

( ) Function.prototype.call Array.prototype.join.

js
function f(a, b, c) {
  var s = Array.prototype.join.call(arguments);
  console.log(s); // '1,a,true'
}
f(1, "a", true);

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


Web Proxy Viewer  |  New URL  |  Original Page