Baseline Widely available
Array
ì¸ì¤í´ì¤ì concat()
ë©ìëë ë ê° ì´ìì ë°°ì´ì ë³í©íë ë° ì¬ì©ë©ëë¤. ì´ ë©ìëë 기존 ë°°ì´ì ë³ê²½íì§ ìê³ , ì ë°°ì´ì ë°íí©ëë¤.
const array1 = ["a", "b", "c"];
const array2 = ["d", "e", "f"];
const array3 = array1.concat(array2);
console.log(array3);
// Expected output: Array ["a", "b", "c", "d", "e", "f"]
구문
concat()
concat(value0)
concat(value0, value1)
concat(value0, value1, /* â¦, */ valueN)
매ê°ë³ì
valueN
Optional
ì ë°°ì´ë¡ ì°ê²°í ë°°ì´ ë°/ëë ê°ì
ëë¤. 모ë valueN
매ê°ë³ìê° ìëµë ê²½ì°, concat
ì í¸ì¶ë 기존 ë°°ì´ì ìì ë³µì¬ë³¸ì ë°íí©ëë¤. ìì¸í ë´ì©ì ìë ì¤ëª
ì 참조íì¸ì.
ìë¡ì´ Array
ê°ì²´.
concat
ë©ìëë ì ë°°ì´ì ë§ëëë¤. 먼ì ë°°ì´ì í¸ì¶ë ê°ì²´ì ììë¡ ì±ìì§ëë¤. ê·¸ë° ë¤ì, ê° ì¸ìì ê°ì´ ë°°ì´ì ì°ê²°ë©ëë¤. ì¼ë° ê°ì²´ë ìì ê°ì ê²½ì°, ì¸ì ìì²´ê° ìµì¢
ë°°ì´ì ììê° ëê³ , Symbol.isConcatSpreadable
ìì±ì´ ì°¸ ê°ì¼ë¡ ì¤ì ë ë°°ì´ ëë ì ì¬ ë°°ì´ ê°ì²´ì¸ ê²½ì°, ì¸ìì ê° ììê° ìµì¢
ë°°ì´ì ë
립ì ì¼ë¡ ì¶ê°ë©ëë¤. concat
ë©ìëë ì¤ì²©ë ë°°ì´ ì¸ìë¡ ì¬ê·íì§ ììµëë¤.
concat()
ë©ìëë ë³µì¬ ë©ìëì
ëë¤. ì´ ë©ìëë ì´ ë°°ì´ ëë ì¸ìë¡ ì ê³µë ë°°ì´ì ë³ê²½íì§ ìë ëì , ìë ë°°ì´ì ììì ëì¼í ìì를 í¬í¨íë ìì ë³µì¬ë³¸ì ë°íí©ëë¤.
concat()
ë©ìëë ìì¤ ë°°ì´ ì¤ íëë¼ë í¬ì ë°°ì´ì´ ìë¤ë©´ ë°°ì´ì ë¹ ì¬ë¡¯ì ë³´ì¡´í©ëë¤.
concat()
ë©ìëë ë²ì© ë©ìëì
ëë¤. this
ê°ì ë¤ë¥¸ ì¸ìì ëì¼í ë°©ìì¼ë¡ ì²ë¦¬ë©ëë¤(ê°ì²´ë¡ 먼ì ë³íëë¤ë ì ì ì ì¸íë©´). ì¦, ì¼ë° ê°ì²´ë ê²°ê³¼ ë°°ì´ ë°ë¡ ìì ë¶ê³ , @@isConcatSpreadable
ì´ ì°¸ì¸ ì ì¬ ë°°ì´ ê°ì²´ë ê²°ê³¼ ë°°ì´ì ì ê°ë©ëë¤.
ë¤ì ìì ë ë ë°°ì´ì ì°ê²°í©ëë¤.
const letters = ["a", "b", "c"];
const numbers = [1, 2, 3];
const alphaNumeric = letters.concat(numbers);
console.log(alphaNumeric);
// ê²°ê³¼ë ['a', 'b', 'c', 1, 2, 3]
ì¸ ë°°ì´ ì°ê²°
ë¤ì ìì ë ì¸ ë°°ì´ì ì°ê²°í©ëë¤.
const num1 = [1, 2, 3];
const num2 = [4, 5, 6];
const num3 = [7, 8, 9];
const numbers = num1.concat(num2, num3);
console.log(numbers);
// ê²°ê³¼ë [1, 2, 3, 4, 5, 6, 7, 8, 9]
ê°ì ë°°ì´ì ì°ê²°
ë¤ì ì½ëë ì¸ ê°ì ê°ì ë°°ì´ì ì°ê²°í©ëë¤.
const letters = ["a", "b", "c"];
const alphaNumeric = letters.concat(1, [2, 3]);
console.log(alphaNumeric);
// ê²°ê³¼ë ['a', 'b', 'c', 1, 2, 3]
ì¤ì²©ë ë°°ì´ ì°ê²°
ë¤ì ì½ëë ì¤ì²©ë ë°°ì´ì ì°ê²°íê³ ì°¸ì¡° ì ì§ë¥¼ ì¤ëª í©ëë¤.
const num1 = [[1]];
const num2 = [2, [3]];
const numbers = num1.concat(num2);
console.log(numbers);
// ê²°ê³¼ë [[1], 2, [3]]
// num1ì 첫 ë²ì§¸ ìì를 ìì í©ëë¤.
num1[0].push(4);
console.log(numbers);
// ê²°ê³¼ë [[1, 4], 2, [3]]
Symbol.isConcatSpreadableì ì´ì©íì¬ ì ì¬ ë°°ì´ ê°ì²´ ì°ê²°
concat
ì 기본ì ì¼ë¡ 모ë ì ì¬ ë°°ì´ ê°ì²´ë¥¼ ë°°ì´ë¡ ì·¨ê¸íì§ ìì¼ë©°, Symbol.isConcatSpreadable
ì´ ì°¸ì¸ ê°(ì: true
)ì¼ë¡ ì¤ì ë ê²½ì°ìë§ ë°°ì´ë¡ ì·¨ê¸í©ëë¤.
const obj1 = { 0: 1, 1: 2, 2: 3, length: 3 };
const obj2 = { 0: 1, 1: 2, 2: 3, length: 3, [Symbol.isConcatSpreadable]: true };
console.log([0].concat(obj1, obj2));
// [ 0, { '0': 1, '1': 2, '2': 3, length: 3 }, 1, 2, 3 ]
í¬ì ë°°ì´ì concat() ì¬ì©
ìì¤ ë°°ì´ ì¤ íëë¼ë í¬ì ë°°ì´ì´ ìì¼ë©´, ê²°ê³¼ ë°°ì´ë í¬ì ë°°ì´ì´ ë©ëë¤.
console.log([1, , 3].concat([4, 5])); // [1, empty, 3, 4, 5]
console.log([1, 2].concat([3, , 5])); // [1, 2, 3, empty, 5]
ë°°ì´ì´ ìë ê°ì²´ì concat() ì¬ì©
this
ê°ì´ ë°°ì´ì´ ìë ê²½ì°, this
를 ê°ì²´ë¡ ë³íë ë¤ì concat()
ì ì¸ìì ëì¼í ë°©ìì¼ë¡ ì²ë¦¬í©ëë¤. ì´ ê²½ì° ë°í ê°ì íì ì¤ì²©ì´ ìë ì ë°°ì´ì
ëë¤.
console.log(Array.prototype.concat.call({}, 1, 2, 3)); // [{}, 1, 2, 3]
console.log(Array.prototype.concat.call(1, 2, 3)); // [ [Number: 1], 2, 3 ]
const arrayLike = {
[Symbol.isConcatSpreadable]: true,
length: 2,
0: 1,
1: 2,
2: 99, // lengthê° 2ì´ë¯ë¡ concat()ìì 무ìë¨
};
console.log(Array.prototype.concat.call(arrayLike, 3, 4)); // [1, 2, 3, 4]
ëª
ì¸ì ë¸ë¼ì°ì í¸íì± ê°ì´ 보기
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4