Baseline Widely available *
ë¤ë¥¸ íë¡ê·¸ëë° ì¸ì´ì ë°°ì´ê³¼ ë§ì°¬ê°ì§ë¡, Array
ê°ì²´ë ì¬ë¬ í목ì 컬ë ì
ì ë¨ì¼ ë³ì ì´ë¦ ìë ì ì¥í ì ìê³ , ì¼ë°ì ì¸ ë°°ì´ ì°ì°ì ìíí기 ìí 멤ë²ê° ììµëë¤.
JavaScriptìì ë°°ì´ì ìì ê°ì´ ìëë¼ ë¤ìê³¼ ê°ì íµì¬ì ì¸ í¹ì±ì ê°ì§ Array
ê°ì²´ì
ëë¤.
0
, ë ë²ì§¸ ììë ì¸ë±ì¤ 1
, ë§ì§ë§ ììë ë°°ì´ì length
ìì± ê°ìì 1ì ëº ê°ì ìì¹í©ëë¤.Array
ê°ì²´ë (ì°ê´ ë°°ì´ììì²ë¼) ììì 문ìì´ì ìì ì¸ë±ì¤ë¡ ì¬ì©í ì ìì¼ë©° ììê° ìë ì ì(ëë í´ë¹ ìì 문ìì´ íì)를 ì¬ì©í´ì¼ í©ëë¤. ì ìê° ìë ê²ì íµí´ ë°°ì´ì ìì를 ì¤ì íê±°ë ì ê·¼íë ¤ê³ íë©´, ë°°ì´ ëª©ë¡ ìì²´ìì ìì를 ì¤ì íê±°ë ê²ìíë ê²ì´ ìëë¼ í´ë¹ ë°°ì´ì ê°ì²´ ìì± ì»¬ë ì
ê³¼ ì°ê²°ë ë³ì를 ì¤ì íê±°ë ì ê·¼íê² ë©ëë¤. ë°°ì´ì ê°ì²´ ìì±ê³¼ ë°°ì´ì ìì 목ë¡ì ë³ê°ì´ë©°, ë°°ì´ì ìí ë° ìì ì°ì°ì ì´ë ê² ì´ë¦ ë¶ì¬ì§ ìì±ì ì ì©í ì ììµëë¤.
ë°°ì´ ììë toString
ì´ ìì±ì¸ ê²ê³¼ ê°ì ë°©ìì¼ë¡ ê°ì²´ ìì±ì
ëë¤(íì§ë§, ì íí ë§íìë©´ toString()
ì ë©ìëì
ëë¤). ê·¸ë¼ìë ë¶êµ¬íê³ ë¤ìê³¼ ê°ì´ ë°°ì´ì ììì ì ê·¼íë ¤ê³ íë©´ ìì± ì´ë¦ì´ ì í¨íì§ ì기 ë문ì 구문 ì¤ë¥ê° ë°ìí©ëë¤.
JavaScript 구문ìì ì«ìë¡ ììíë ìì±ì ì íê¸°ë² ëì ëê´í¸ í기ë²ì ì¬ì©íì¬ ì ê·¼í´ì¼ í©ëë¤. ë°°ì´ ì¸ë±ì¤ë¥¼ ë°ì´íë¡ ë¬¶ì ìë ìì§ë§ (ì: years[2]
ëì years['2']
), ì¼ë°ì ì¼ë¡ë íìíì§ ììµëë¤.
years[2]
ì 2
ë JavaScript ìì§ì ìí´ ììì toString
ë³íì íµí´ 문ìì´ë¡ ê°ì ë³íë©ëë¤. ê²°ê³¼ì ì¼ë¡ '2'
ì '02'
ë years
ê°ì²´ìì ìë¡ ë¤ë¥¸ ë ê°ì ì¬ë¡¯ì 참조íê² ëë©°, ë¤ì ìì ë true
ì¼ ì ììµëë¤.
console.log(years["2"] !== years["02"]);
years['2']
ë§ì´ ì¤ì ë°°ì´ ì¸ë±ì¤ì
ëë¤. years['02']
ë ë°°ì´ ìíìì 방문ëì§ ìë ììì 문ìì´ ìì±ì
ëë¤.
JavaScript ë°°ì´ì length
ìì±ê³¼ ì«ì ìì±ì ì°ê²°ëì´ ììµëë¤.
ë´ì¥ ë°°ì´ ë©ìë ì¤ ì¼ë¶(ì: join()
, slice()
, indexOf()
ë±)ë í¸ì¶ ì ë°°ì´ì length
ìì± ê°ì ê³ ë ¤í©ëë¤.
ë¤ë¥¸ ë©ìë(ì: push()
, splice()
ë±)ë ë°°ì´ì length
ìì±ì ê°±ì í©ëë¤.
const fruits = [];
fruits.push("banana", "apple", "peach");
console.log(fruits.length); // 3
ìì±ì´ ì í¨í ë°°ì´ ì¸ë±ì¤ì´ê³ í´ë¹ ì¸ë±ì¤ê° ë°°ì´ì íì¬ ë²ì를 ë²ì´ë ë JavaScript ë°°ì´ì ìì±ì ì¤ì íë©´, ìì§ì ë°°ì´ì length
ìì±ì ì ì í ê°±ì í©ëë¤.
fruits[5] = "mango";
console.log(fruits[5]); // 'mango'
console.log(Object.keys(fruits)); // ['0', '1', '2', '5']
console.log(fruits.length); // 6
length
를 ë리면 ì ìì를 ë§ë¤ì§ ìê³ ë¹ ì¬ë¡¯ì ì¶ê°íì¬ ë°°ì´ì íì¥í ì ììµëë¤. undefined
ê° ìëëë¤.
fruits.length = 10;
console.log(fruits); // ['banana', 'apple', 'peach', empty x 2, 'mango', empty x 4]
console.log(Object.keys(fruits)); // ['0', '1', '2', '5']
console.log(fruits.length); // 10
console.log(fruits[8]); // undefined
ê·¸ë¬ë length
ìì±ì ì¤ì´ë©´ ììê° ìì ë©ëë¤.
fruits.length = 2;
console.log(Object.keys(fruits)); // ['0', '1']
console.log(fruits.length); // 2
length
íì´ì§ìì ë ìì¸í ì¤ëª
íê² ìµëë¤.
í¬ì ë°°ì´ì ë¹ ì¬ë¡¯ì ë°°ì´ ë©ìë ê°ì ì¼ê´ì± ìì´ ëìí©ëë¤. ì¼ë°ì ì¼ë¡ ì¤ëë ë©ìëë ë¹ ì¬ë¡¯ì ê±´ëë°ë ë°ë©´, ìµì ë©ìëë ë¹ ì¬ë¡¯ì undefined
ë¡ ì²ë¦¬í©ëë¤.
ì¬ë¬ ìì를 ìííë ë©ìë ì¤, ë¤ìì ì¸ë±ì¤ì ì ê·¼í기 ì ì in
íì¸ì ìííì¬ ë¹ ì¬ë¡¯ì undefined
ë¡ ì·¨ê¸íì§ ììµëë¤.
concat()
copyWithin()
every()
filter()
flat()
flatMap()
forEach()
indexOf()
lastIndexOf()
map()
reduce()
reduceRight()
reverse()
slice()
some()
sort()
splice()
ë¹ ì¬ë¡¯ì ì íí ì´ë»ê² ì²ë¦¬íëì§ë ê° ë©ìëì íì´ì§ë¥¼ 참조íì¸ì.
ìë ë©ìëë ë¹ ì¬ë¡¯ì undefined
ë¡ ì·¨ê¸í©ëë¤.
entries()
fill()
find()
findIndex()
findLast()
findLastIndex()
includes()
join()
keys()
toLocaleString()
values()
ì¼ë¶ ë©ìëë ë©ìëê° í¸ì¶ë 기존 ë°°ì´ì ë³ê²½íì§ ìë ëì , ì ë°°ì´ì ë°íí©ëë¤. ì´ë¬í ë©ìëë 먼ì ì ë°°ì´ì 구ì±í ë¤ì ìì를 ì±ì°ë ë°©ìì¼ë¡ ìíë©ëë¤. ë³µì¬ë íì ìê² ì´ë£¨ì´ì§ë©°, ë©ìëë ì²ìì ìì±ë ë°°ì´ ì´ì¸ìë ì무ê²ë ë³µì¬íì§ ììµëë¤. ìë ë°°ì´ì ììë ë¤ìê³¼ ê°ì´ ì ë°°ì´ì ë³µì¬ë©ëë¤
String
, Number
, Boolean
ê°ì²´ ìë): í´ë¹ ê°ì´ ì ë°°ì´ì ë³µì¬ë©ëë¤.ì´ë¤ ë©ìëë ë©ìëê° í¸ì¶ë ë°°ì´ì ë³ê²½íë©°, ì´ ê²½ì° ë°íê°ì ë©ìëì ë°ë¼ ë¤ë¦ ëë¤. ëë¡ë ê°ì ë°°ì´ì ëí 참조를 ë°ííê³ , ëë¡ë ì ë°°ì´ì 길ì´ë¥¼ ë°íí©ëë¤.
ë¤ì ë©ìëë this.constructor[Symbol.species]
ì ì ê·¼íì¬ ì¬ì©í ìì±ì를 ê²°ì íê³ ì ë°°ì´ì ìì±í©ëë¤.
concat()
filter()
flat()
flatMap()
map()
slice()
splice()
(ë°íëë ì ê±°ë ììì ë°°ì´ì 구ì±í기 ìí´)ë¤ì ë©ìëë íì Array
기본 ìì±ì를 ì¬ì©íì¬ ì ë°°ì´ì ìì±í©ëë¤.
ìë íìë ìë ë°°ì´ì ë³ê²½íë ë©ìëì ê·¸ì ììíë 무ë³ê²½ ëì²´ ë©ìëê° ëì´ëì´ ììµëë¤.
ë³ê²½ ë©ìë를 무ë³ê²½ ëì²´ ë©ìëë¡ ë³ê²½íë ì¬ì´ ë°©ë²ì ì ê° êµ¬ë¬¸ ëë slice()
를 ì¬ì©íì¬ ë¨¼ì ë³µì¬ë³¸ì ë§ëë ê²ì
ëë¤.
arr.copyWithin(0, 1, 2); // arrì ë³ê²½í¨
const arr2 = arr.slice().copyWithin(0, 1, 2); // arrì ë³ê²½íì§ ìì
const arr3 = [...arr].copyWithin(0, 1, 2); // arrì ë³ê²½íì§ ìì
ìí ë©ìë
ë§ì ë°°ì´ ë©ìëë ì½ë°± í¨ì를 ì¸ìë¡ ë°ìµëë¤. ì½ë°± í¨ìë ë°°ì´ì ê° ììì ëí´ ìì°¨ì ì¼ë¡ ìµë í ë²ë§ í¸ì¶ëë©°, ì½ë°± í¨ìì ë°íê°ì ë©ìëì ë°íê°ì ê²°ì íë ë° ì¬ì©ë©ëë¤. ì´ë¤ì 모ë ê°ì 모ìµì ê³µì í©ëë¤.
method(callbackFn, thisArg)
ì¬ê¸°ì callbackFn
ì ì¸ ê°ì ì¸ì를 ë°ìµëë¤.
element
ë°°ì´ìì íì¬ ì²ë¦¬ ì¤ì¸ ììì ëë¤.
index
ë°°ì´ìì íì¬ ì²ë¦¬ ì¤ì¸ ììì ì¸ë±ì¤ì ëë¤.
array
ë©ìëê° í¸ì¶ë ë°°ì´ì ëë¤.
callbackFn
ì´ ë°íí ê²ì¼ë¡ ììëë ê²ì í¸ì¶ë ë°°ì´ ë©ìëì ë°ë¼ ë¤ë¦
ëë¤.
callbackFn
ì í¸ì¶í ë thisArg
ì¸ì(기본ê°ì undefined
)ë this
ê°ì´ ì¬ì©ë©ëë¤. callbackFn
ì´ ìµì¢
ì ì¼ë¡ ê´ì°°í ì ìë this
ê°ì ì¼ë°ì ì¸ ê·ì¹ì ë°ë¼ ê²°ì ë©ëë¤. callbackFn
ì´ ë¹ì격ì´ë¼ë©´, ìì this
ê°ì ê°ì²´ë¡ ëíëê³ , undefined
/null
ì globalThis
ë¡ ëì²´ë©ëë¤. íì´í í¨ììë ìì²´ this
ë°ì¸ë©ì´ ìì¼ë¯ë¡ thisArg
ì¸ìë íì´í í¨ìë¡ ì ìë callbackFn
ê³¼ ê´ë ¨ì´ ììµëë¤.
모ë ìí ë©ìëë ë³µì¬ì ë²ì© ë©ìë ì´ì§ë§, ë¹ ì¬ë¡¯ììë ë¤ë¥´ê² ëìí©ëë¤.
ë¤ì ë©ìëë ìí ë©ìëì ëë¤.
í¹í, every()
, find()
, findIndex()
, findLast()
, findLastIndex()
, some()
ë 모ë ììì ëí´ íì callbackFn
ì í¸ì¶íë ê²ì´ ìëë¼, ë°í ê°ì´ ê²°ì ëë ì¦ì ìí를 ì¤ì§í©ëë¤.
ì½ë°± í¨ì를 ë°ì ë°°ì´ì ê° ììì ëí´ ìµë í ë²ë§ ì¤ííë ë¤ë¥¸ ë ê°ì§ ë©ìëê° ìì§ë§, ì¼ë°ì ì¸ ìí ë©ìëìë ì½ê° ë¤ë¥¸ 모ìµì ê°ì§ëë¤(ì: thisArg
를 íì©íì§ ìì).
sort()
ë©ìëë ì½ë°± í¨ì를 ë°ì§ë§, ìí ë©ìëë ìëëë¤. ì´ ë©ìëë ë°°ì´ì ì ì리ìì ë³ê²½íê³ , thisArg
를 íì©íì§ ìì¼ë©°, í ì¸ë±ì¤ìì ì½ë°±ì ì¬ë¬ ë² í¸ì¶í ì ììµëë¤.
ë°°ì´ ë©ìëë íì ë²ì©ì ì´ê³ , ì´ë ë°°ì´ ê°ì²´ì ë´ë¶ ë°ì´í°ì ì ê·¼íì§ ììµëë¤. length
ìì±ê³¼ ì¸ë±ì¤ë ìì를 íµí´ìë§ ë°°ì´ ììì ì ê·¼í©ëë¤. ì¦, ì ì¬ ë°°ì´ ê°ì²´ììë ì´ ë©ìë를 í¸ì¶í ì ììµëë¤.
const arrayLike = {
0: "a",
1: "b",
length: 2,
};
console.log(Array.prototype.join.call(arrayLike, "+")); // 'a+b'
length ìì± ì¼ë°í
length
ìì±ì ì ìë¡ ë³íë ë¤ì 0ìì 253 - 1 ì¬ì´ì ë²ìë¡ ê³ ì ë©ëë¤. NaN
ì 0
ì´ ëë¯ë¡, length
ê° ìê±°ë undefined
ì¸ ê²½ì°ìë 0
ê°ì´ ìë ê²ì²ë¼ ëìí©ëë¤.
ì´ ì¸ì´ë length
를 ìì íì§ ìì ì ìë¡ ì¤ì íì§ ëª»íëë¡ í©ëë¤. 모ë ë´ì¥ ë©ìëë length
ê° 253 - 1ë³´ë¤ í° ì«ìë¡ ì¤ì ë ë TypeError
를 ë°ììíµëë¤. ê·¸ë¬ë ë°°ì´ì length
ìì±ì´ 232 - 1ë³´ë¤ í° ê°ì¼ë¡ ì¤ì ëë©´ ì¤ë¥ê° ë°ìí기 ë문ì ë°°ì´ì´ ìë ê°ì²´ìì ë©ìë를 í¸ì¶íì§ ìë í ì¼ë°ì ì¼ë¡ ìì í ì ì ìê³ê°ì ëë¬íì§ ëª»í©ëë¤.
Array.prototype.flat.call({}); // []
ì¼ë¶ ë°°ì´ ë©ìëë ë°°ì´ ê°ì²´ì length
ìì±ì ì¤ì í©ëë¤. ì´ë¬í ë©ìëë íì ì¼ë°íí í ê°ì ì¤ì íë¯ë¡ length
ë íì ì ìë¡ ëë©ëë¤.
const a = { length: 0.7 };
Array.prototype.push.call(a);
console.log(a.length); // 0
ì ì¬ ë°°ì´ ê°ì²´
ì ì¬ ë°°ì´ ê°ì²´ë¼ë ì©ì´ë ììì ì¤ëª
í length
ë³í íë¡ì¸ì¤ ì¤ì ì¤ë¥ê° ë°ìíì§ ìë 모ë ê°ì²´ë¥¼ ì미í©ëë¤. ì¤ì ë¡ ì´ë¬í ê°ì²´ë ì ë§ length
ìì±ì ê°ì§ë©°, 0
ìì length - 1
ë²ìì ì¸ë±ì¤ ìì를 ê°ì§ ê²ì¼ë¡ ììë©ëë¤. (모ë ì¸ë±ì¤ê° ìë ê²½ì°, 기ë¥ì ì¼ë¡ í¬ì ë°°ì´ê³¼ ëì¼í©ëë¤.) ë°°ì´ ë©ìëê° ì ì¬ ë°°ì´ ê°ì²´ìì ìëí ë 0
ë³´ë¤ ìê±°ë length - 1
ë³´ë¤ í° ì ìì ì¸ë±ì¤ë 무ìë©ëë¤.
ë§ì DOM ê°ì²´ë ì ì¬ ë°°ì´ì
ëë¤(ì: NodeList
ì HTMLCollection
). arguments
ê°ì²´ë ì ì¬ ë°°ì´ì
ëë¤. ì ì¬ ë°°ì´ì ë°°ì´ ë©ìëê° ìëë¼ë ë°°ì´ ë©ìë를 í¸ì¶í ì ììµëë¤.
function f() {
console.log(Array.prototype.join.call(arguments, "+"));
}
f("a", "b"); // 'a+b'
ìì±ì
Array()
ì Array
ê°ì²´ë¥¼ ìì±í©ëë¤.
Array[@@species]
Array
ìì±ì를 ë°íí©ëë¤.
Array.from()
ìí ê°ë¥ ëë ì ì¬ ë°°ì´ ê°ì²´ìì ì Array
ì¸ì¤í´ì¤ë¥¼ ìì±í©ëë¤.
Array.fromAsync()
ë¹ë기 ìí ê°ë¥, ìí ê°ë¥, ëë ì ì¬ ë°°ì´ ê°ì²´ìì ì Array
ì¸ì¤í´ì¤ë¥¼ ìì±í©ëë¤.
Array.isArray()
ì¸ìê° ë°°ì´ì´ë©´ true
를 ë°ííê³ , ê·¸ë ì§ ìì¼ë©´ false
를 ë°íí©ëë¤.
Array.of()
ì¸ìì ê°ìë ì íì ê´ê³ìì´ ê°ë³ì ì¸ ìì ì¸ì를 ê°ì§ ì Array
ì¸ì¤í´ì¤ë¥¼ ìì±í©ëë¤.
ìë ìì±ì Array.prototype
ì ì ìëë©° 모ë Array
ì¸ì¤í´ì¤ìì ê³µì ë©ëë¤.
Array.prototype.constructor
ì¸ì¤í´ì¤ ê°ì²´ë¥¼ ìì±í ìì±ì í¨ìì
ëë¤. Array
ì¸ì¤í´ì¤ì ê²½ì°, ì´ê¸° ê°ì Array
ìì±ìì
ëë¤.
Array.prototype[@@unscopables]
ES2015 ë²ì ì´ì ì ECMAScript íì¤ì í¬í¨ëì§ ììì¼ë©° with
문 ë°ì¸ë© 목ì ì¼ë¡ 무ìëë ìì± ì´ë¦ì í¬í¨í©ëë¤.
ìë ìì±ì ê° Array
ì¸ì¤í´ì¤ì ê³ ì ìì±ì
ëë¤.
length
ë°°ì´ ììì ê°ì를 ë°ìí©ëë¤.
Array.prototype.at()
주ì´ì§ ì¸ë±ì¤ì ìë ë°°ì´ì í목ì ë°íí©ëë¤. ë§ì§ë§ í목ë¶í° ì ì ìë ìì ì ì를 íì©í©ëë¤.
Array.prototype.concat()
ë¤ë¥¸ ë°°ì´ ë°/ëë ê°ê³¼ ê²°í©ë í¸ì¶ ë°°ì´ì¸ ì ë°°ì´ì ë°íí©ëë¤.
Array.prototype.copyWithin()
ë°°ì´ ë´ì ë°°ì´ ìì ìíì¤ë¥¼ ë³µì¬í©ëë¤.
Array.prototype.entries()
ë°°ì´ì ê° ì¸ë±ì¤ì ëí í¤/ê° ìì í¬í¨íë ì ë°°ì´ ë°ë³µì ê°ì²´ë¥¼ ë°íí©ëë¤.
Array.prototype.every()
í¸ì¶ ë°°ì´ì 모ë ììê° í
ì¤í¸ í¨ì를 ë§ì¡±íë©´ true
를 ë°íí©ëë¤.
Array.prototype.fill()
ìì ì¸ë±ì¤ë¶í° ë ì¸ë±ì¤ê¹ì§ ë°°ì´ì 모ë ìì를 ê³ ì ë ê°ì¼ë¡ ì±ìëë¤.
Array.prototype.filter()
ì ê³µë íí°ë§ í¨ìê° true
를 ë°ííë í¸ì¶ ë°°ì´ì 모ë ìì를 í¬í¨íë ì ë°°ì´ì ë°íí©ëë¤.
Array.prototype.find()
ì ê³µë í
ì¤í¸ í¨ì를 ë§ì¡±íë ë°°ì´ì 첫 ë²ì§¸ ììì ê°ì ë°ííê³ , ì ì í ìì를 ì°¾ì ì ìì¼ë©´ undefined
를 ë°íí©ëë¤.
Array.prototype.findIndex()
ì ê³µë í
ì¤í¸ í¨ì를 ë§ì¡±íë ë°°ì´ì 첫 ë²ì§¸ ììì ì¸ë±ì¤ë¥¼ ë°ííê³ , ì ì í ìì를 ì°¾ì ì ìì¼ë©´ -1
ì ë°íí©ëë¤.
Array.prototype.findLast()
ì ê³µë í
ì¤í¸ í¨ì를 ë§ì¡±íë ë°°ì´ì ë§ì§ë§ ììì ê°ì ë°ííê³ , ì ì í ìì를 ì°¾ì ì ìì¼ë©´ undefined
를 ë°íí©ëë¤.
Array.prototype.findLastIndex()
ì ê³µë í
ì¤í¸ í¨ì를 ë§ì¡±íë ë°°ì´ì ë§ì§ë§ ììì ì¸ë±ì¤ë¥¼ ë°ííê³ , ì ì í ìì를 ì°¾ì ì ìë ê²½ì° -1
ì ë°íí©ëë¤.
Array.prototype.flat()
ì§ì ë ê¹ì´ê¹ì§ ì¬ê·ì ì¼ë¡ ì°ê²°ë 모ë íì ë°°ì´ ììê° í¬í¨ë ì ë°°ì´ì ë°íí©ëë¤.
Array.prototype.flatMap()
í¸ì¶ ë°°ì´ì ê° ììì ì§ì ë ì½ë°± í¨ì를 ì ì©í ë¤ì 결과를 í ë¨ê³ì© ííííì¬ ë§ë¤ì´ì§ ì ë°°ì´ì ë°íí©ëë¤.
Array.prototype.forEach()
í¸ì¶ ë°°ì´ì ê° ììë¡ í¨ì를 í¸ì¶í©ëë¤.
Array.prototype.includes()
í¸ì¶íë ë°°ì´ì ê°ì´ í¬í¨ëì´ ìëì§ ì¬ë¶ë¥¼ íë¨íì¬ ì ì íê² true
ëfalse
를 ë°íí©ëë¤.
Array.prototype.indexOf()
í¸ì¶ ë°°ì´ìì ì§ì ë ìì를 ì°¾ì ì ìë 첫 ë²ì§¸(ìµì) ì¸ë±ì¤ë¥¼ ë°íí©ëë¤.
Array.prototype.join()
ë°°ì´ì 모ë ìì를 문ìì´ë¡ ê²°í©í©ëë¤.
Array.prototype.keys()
í¸ì¶ ë°°ì´ì ê° ì¸ë±ì¤ì ëí í¤ë¥¼ í¬í¨íë ì ë°°ì´ ë°ë³µì를 ë°íí©ëë¤.
Array.prototype.lastIndexOf()
í¸ì¶ ë°°ì´ìì ì§ì ë ìì를 ì°¾ì ì ìë ë§ì§ë§(ê°ì¥ í°) ì¸ë±ì¤ë¥¼ ë°ííê³ , ì°¾ì ì ìë ê²½ì° -1
ì ë°íí©ëë¤.
Array.prototype.map()
í¸ì¶ ë°°ì´ì 모ë ììì í¨ì를 í¸ì¶í 결과를 í¬í¨íë ì ë°°ì´ì ë°íí©ëë¤.
Array.prototype.pop()
ë°°ì´ìì ë§ì§ë§ ìì를 ì ê±°íê³ í´ë¹ ìì를 ë°íí©ëë¤.
Array.prototype.push()
ë°°ì´ ëì íë ì´ìì ìì를 ì¶ê°íê³ , ë°°ì´ì ì length
를 ë°íí©ëë¤.
Array.prototype.reduce()
ë°°ì´ì ê° ìì(ì¼ìª½ìì ì¤ë¥¸ìª½ì¼ë¡)ì ëí´ ì¬ì©ìê° ì ê³µí "리ëì" ì½ë°± í¨ì를 ì¤ííì¬ íëì ê°ì¼ë¡ ì¤ì ëë¤.
Array.prototype.reduceRight()
ë°°ì´ì ê° ìì(ì¤ë¥¸ìª½ìì ì¼ìª½ì¼ë¡)ì ëí´ ì¬ì©ìê° ì ê³µí "리ëì" ì½ë°± í¨ì를 ì¤ííì¬ íëì ê°ì¼ë¡ ì¤ì ëë¤.
Array.prototype.reverse()
ë°°ì´ ììì ìì를 ë°ëë¡ ë°ê¿ëë¤. (첫 ë²ì§¸ê° ë§ì§ë§ì´ ëê³ , ë§ì§ë§ì´ 첫 ë²ì§¸ê° ë©ëë¤.)
Array.prototype.shift()
ë°°ì´ìì 첫 ë²ì§¸ ìì를 ì ê±°íê³ í´ë¹ ìì를 ë°íí©ëë¤.
Array.prototype.slice()
í¸ì¶ ë°°ì´ì 구íì ì¶ì¶íê³ ì ë°°ì´ì ë°íí©ëë¤.
Array.prototype.some()
í¸ì¶ ë°°ì´ì ìì ì¤ íë ì´ìì´ ì ê³µë í
ì¤í¸ í¨ì를 ë§ì¡±íë©´ true
를 ë°íí©ëë¤.
Array.prototype.sort()
ë°°ì´ì ìì를 ì ì리 ì ë ¬íê³ ë°°ì´ì ë°íí©ëë¤.
Array.prototype.splice()
ë°°ì´ìì ìì를 ì¶ê° ë°/ëë ì ê±°í©ëë¤.
Array.prototype.toLocaleString()
í¸ì¶ ë°°ì´ê³¼ ê·¸ ìì를 ëíë´ë ì§ìíë 문ìì´ì ë°íí©ëë¤. Object.prototype.toLocaleString()
ë©ìë를 ì¬ì ìí©ëë¤.
Array.prototype.toReversed()
ìë ë°°ì´ì ìì íì§ ìê³ , ììê° ììì¼ë¡ ë°°ì´ë ì ë°°ì´ì ë°íí©ëë¤.
Array.prototype.toSorted()
ìë ë°°ì´ì ìì íì§ ìê³ , ì¤ë¦ì°¨ìì¼ë¡ ì ë ¬ë ììê° ìë ì ë°°ì´ì ë°íí©ëë¤.
Array.prototype.toSpliced()
ìë ë°°ì´ì ìì íì§ ìê³ , ì§ì ë ì¸ë±ì¤ìì ì¼ë¶ ìì를 ì ê±° ë°/ëë êµì²´í ì ë°°ì´ì ë°íí©ëë¤.
Array.prototype.toString()
í¸ì¶ ë°°ì´ê³¼ ê·¸ ìì를 ëíë´ë 문ìì´ì ë°íí©ëë¤. Object.prototype.toString()
ë©ìë를 ì¬ì ìí©ëë¤.
Array.prototype.unshift()
ë°°ì´ ì쪽ì íë ì´ìì ìì를 ì¶ê°íê³ , ë°°ì´ì ì length
를 ë°íí©ëë¤.
Array.prototype.values()
ë°°ì´ì ê° ì¸ë±ì¤ì ê°ì í¬í¨íë ì ë°°ì´ ìíì ê°ì²´ë¥¼ ë°íí©ëë¤.
Array.prototype.with()
ìë ë°°ì´ì ìì íì§ ìê³ , ì§ì ë ì¸ë±ì¤ì ìì를 ì§ì ë ê°ì¼ë¡ ë°ê¾¼ ì ë°°ì´ì ë°íí©ëë¤.
Array.prototype[@@iterator]()
기본ì ì¼ë¡ values()
ë©ìëì ë³ì¹ì
ëë¤.
ì´ êµ¬íì JavaScriptìì íí ì¬ì©ëë ë°°ì´ ì°ì°ì ëí ëª ê°ì§ ìì 를 ì ê³µí©ëë¤.
ì°¸ê³ : ë°°ì´ì 기ì´ê° ìì§ ìµìíì§ ìë¤ë©´, 먼ì JavaScript 첫걸ì: ë°°ì´ì ì½ì´ë³´ì¸ì. ì´ê³³ì ë°°ì´ì´ 무ìì¸ì§ ì¤ëª íê³ ì¼ë°ì ì¸ ë°°ì´ ì°ì°ì ëí ë¤ë¥¸ ìì 를 í¬í¨íê³ ììµëë¤.
ë°°ì´ ë§ë¤ê¸°ì´ ìì ë 먼ì ë°°ì´ ë¦¬í°ë´ í기ë²ì ì¬ì©íê³ , ë¤ìì Array()
ìì±ì를 ì¬ì©íê³ , ë§ì§ë§ì¼ë¡ 문ìì´ìì ë°°ì´ì ìì±íë String.prototype.split()
ì ì¬ì©íì¬ ì ë°°ì´ì ë§ëë ì¸ ê°ì§ ë°©ë²ì ë³´ì¬ ì¤ëë¤.
// ë°°ì´ ë¦¬í°ë´ í기ë²ì ì¬ì©íì¬ 'fruits' ë°°ì´ì ë§ëëë¤.
console.log(fruits.length);
// 2
// Array() ìì±ì를 ì¬ì©íì¬ 'fruits2' ë°°ì´ì ë§ëëë¤.
const fruits2 = new Array("Apple", "Banana");
console.log(fruits2.length);
// 2
// String.prototype.split()ì ì¬ì©íì¬ 'fruits3' ë°°ì´ì ë§ëëë¤.
const fruits3 = "Apple, Banana".split(", ");
console.log(fruits3.length);
// 2
ë°°ì´ìì 문ìì´ ë§ë¤ê¸°
ì´ ìì ììë join()
ë©ìë를 ì¬ì©íì¬ fruits
ë°°ì´ë¡ 문ìì´ì ë§ëëë¤.
const fruits = ["Apple", "Banana"];
const fruitsString = fruits.join(", ");
console.log(fruitsString);
// "Apple, Banana"
ë°°ì´ ì¸ë±ì¤ë¡ í목ì ì ê·¼í기
ì´ ìì ë ë°°ì´ìì í´ë¹ ìì¹ì ì¸ë±ì¤ ë²í¸ë¥¼ ì§ì íì¬ fruits
ë°°ì´ í목ì ì ê·¼íë ë°©ë²ì ë³´ì¬ ì¤ëë¤.
const fruits = ["Apple", "Banana"];
// ë°°ì´ì 첫 ë²ì§¸ ììì ì¸ë±ì¤ë íì 0ì
ëë¤.
fruits[0]; // Apple
// ë°°ì´ì ë ë²ì§¸ ììì ì¸ë±ì¤ë íì 1ì
ëë¤.
fruits[1]; // Banana
// ë°°ì´ì ë§ì§ë§ ììì ì¸ë±ì¤ë íì
// ë°°ì´ì 길ì´ë³´ë¤ 1 ììµëë¤.
fruits[fruits.length - 1]; // Banana
// ë°°ì´ì 길ì´ë³» í° ì¸ë±ì¤ë¥¼ ì¬ì©íë©´
// undefinedê° ë°íë©ëë¤.
fruits[99]; // undefined
ë°°ì´ìì í목ì ì¸ë±ì¤ 찾기
ì´ ìì ë indexOf()
ë©ìë를 ì¬ì©íì¬ fruits
ë°°ì´ìì 문ìì´ "Banana"
ì ìì¹(ì¸ë±ì¤)를 ì°¾ìµëë¤.
const fruits = ["Apple", "Banana"];
console.log(fruits.indexOf("Banana"));
// 1
ë°°ì´ì í¹ì íëª©ì´ í¬í¨ëì´ ìëì§ íì¸
ì´ ìì ë fruits
ë°°ì´ì "Banana"
ì "Cherry"
ê° í¬í¨ëì´ ìëì§ íì¸íë ë ê°ì§ ë°©ë²ì ë³´ì¬ì¤ëë¤. 먼ì includes()
ë©ìë를 ì¬ì©í ë¤ì, indexOf()
ë©ìë를 ì¬ì©íì¬ ì¸ë±ì¤ê° -1
ì´ ìëì§ í
ì¤í¸í©ëë¤.
const fruits = ["Apple", "Banana"];
fruits.includes("Banana"); // true
fruits.includes("Cherry"); // false
// indexOf()ê° -1ì ë°ííì§ ìì¼ë©´ ë°°ì´ì ì§ì ë íëª©ì´ í¬í¨ëì´ ììµëë¤.
fruits.indexOf("Banana") !== -1; // true
fruits.indexOf("Cherry") !== -1; // false
ë°°ì´ì í목 ì¶ê°í기
ì´ ìì ë push()
ë©ìë를 ì¬ì©íì¬ fruits
ë°°ì´ì ì 문ìì´ì ì¶ê°í©ëë¤.
const fruits = ["Apple", "Banana"];
const newLength = fruits.push("Orange");
console.log(fruits);
// ["Apple", "Banana", "Orange"]
console.log(newLength);
// 3
ë°°ì´ìì ë§ì§ë§ í목 ì ê±°í기
ì´ ìì ë pop()
ë©ìë를 ì¬ì©íì¬ fruits
ë°°ì´ìì ë§ì§ë§ í목ì ì ê±°í©ëë¤.
const fruits = ["Apple", "Banana", "Orange"];
const removedItem = fruits.pop();
console.log(fruits);
// ["Apple", "Banana"]
console.log(removedItem);
// Orange
ë°°ì´ì ëìì ì¬ë¬ í목 ì ê±°íê¸°ì°¸ê³ :
pop()
ì ë°°ì´ìì ë§ì§ë§ í목ì ì ê±°íë ë°ìë§ ì¬ì©í ì ììµëë¤. ë°°ì´ì ëìì ì¬ë¬ í목ì ì ê±°íë ¤ë©´ ë¤ì ìì 를 참조íì¸ì.
ì´ ìì ë splice()
ë©ìë를 ì¬ì©íì¬ fruits
ë°°ì´ìì ë§ì§ë§ 3ê° í목ì ì ê±°í©ëë¤.
const fruits = ["Apple", "Banana", "Strawberry", "Mango", "Cherry"];
const start = -3;
const removedItems = fruits.splice(start);
console.log(fruits);
// ["Apple", "Banana"]
console.log(removedItems);
// ["Strawberry", "Mango", "Cherry"]
ë°°ì´ì ì²ì Nê°ì í목ì¼ë¡ë§ ìë¼ë´ê¸°
ì´ ìì ë splice()
ë©ìë를 ì¬ì©íì¬ fruits
ë°°ì´ì ì²ì ë í목ì¼ë¡ë§ ìë¼ë
ëë¤.
const fruits = ["Apple", "Banana", "Strawberry", "Mango", "Cherry"];
const start = 2;
const removedItems = fruits.splice(start);
console.log(fruits);
// ["Apple", "Banana"]
console.log(removedItems);
// ["Strawberry", "Mango", "Cherry"]
ë°°ì´ìì 첫 ë²ì§¸ í목 ì ê±°í기
ì´ ìì ë shift()
ë©ìë를 ì¬ì©íì¬ fruits
ë°°ì´ìì 첫 ë²ì§¸ í목ì ì ê±°í©ëë¤.
const fruits = ["Apple", "Banana"];
const removedItem = fruits.shift();
console.log(fruits);
// ["Banana"]
console.log(removedItem);
// Apple
ë°°ì´ì ìì ë¶ë¶ìì ì¬ë¬ í목 ì ê±°íê¸°ì°¸ê³ :
shift()
ë ë°°ì´ìì 첫 ë²ì§¸ í목ì ì ê±°íë ë°ìë§ ì¬ì©í ì ììµëë¤. ë°°ì´ì ìì ë¶ë¶ìì ì¬ë¬ í목ì ì ê±°íë ¤ë©´ ë¤ì ìì 를 참조íì¸ì.
ì´ ìì ë splice()
ë©ìë를 ì¬ì©íì¬ fruits
ë°°ì´ìì ì²ì 3ê°ì í목ì ì ê±°í©ëë¤.
const fruits = ["Apple", "Strawberry", "Cherry", "Banana", "Mango"];
const start = 0;
const deleteCount = 3;
const removedItems = fruits.splice(start, deleteCount);
console.log(fruits);
// ["Banana", "Mango"]
console.log(removedItems);
// ["Apple", "Strawberry", "Cherry"]
ë°°ì´ì ìë¡ì´ 첫 ë²ì§¸ í목 ì¶ê°í기
ì´ ìì ë unshift()
ë©ìë를 ì¬ì©íì¬ fruits
ë°°ì´ì ì¸ë±ì¤ 0
ì ì í목ì ì¶ê°íê³ ë°°ì´ì ì 첫 ë²ì§¸ í목ì¼ë¡ ë§ëëë¤.
const fruits = ["Banana", "Mango"];
const newLength = fruits.unshift("Strawberry");
console.log(fruits);
// ["Strawberry", "Banana", "Mango"]
console.log(newLength);
// 3
ì¸ë±ì¤ë¡ ë¨ì¼ í목 ì ê±°í기
ì´ ìì ë splice()
ë©ìë를 ì¬ì©íì¬ "Banana"
ì ì¸ë±ì¤ ìì¹ë¥¼ ì§ì íì¬ fruits
ë°°ì´ìì 문ìì´ "Banana"
를 ì ê±°í©ëë¤.
const fruits = ["Strawberry", "Banana", "Mango"];
const start = fruits.indexOf("Banana");
const deleteCount = 1;
const removedItems = fruits.splice(start, deleteCount);
console.log(fruits);
// ["Strawberry", "Mango"]
console.log(removedItems);
// ["Banana"]
ì¸ë±ì¤ë¡ ì¬ë¬ í목 ì ê±°í기
ì´ ìì ë splice()
ë©ìë를 ì¬ì©íì¬ fruits
ë°°ì´ìì 문ìì´ "Banana"
ì "Strawberry"
를 ì ê±°íëë°, "Banana"
ì ì¸ë±ì¤ ìì¹ì ì ê±°í ì´ í목 ì를 ì§ì íì¬ ì ê±°í©ëë¤.
const fruits = ["Apple", "Banana", "Strawberry", "Mango"];
const start = 1;
const deleteCount = 2;
const removedItems = fruits.splice(start, deleteCount);
console.log(fruits);
// ["Apple", "Mango"]
console.log(removedItems);
// ["Banana", "Strawberry"]
ë°°ì´ì ì¬ë¬ í목 ë°ê¾¸ê¸°
ì´ ìì ë splice()
ë©ìë를 ì¬ì©íì¬ fruits
ë°°ì´ì ë§ì§ë§ 2ê° í목ì ì í목ì¼ë¡ ë°ê¿ëë¤.
const fruits = ["Apple", "Banana", "Strawberry"];
const start = -2;
const deleteCount = 2;
const removedItems = fruits.splice(start, deleteCount, "Mango", "Cherry");
console.log(fruits);
// ["Apple", "Mango", "Cherry"]
console.log(removedItems);
// ["Banana", "Strawberry"]
ë°°ì´ ìíí기
ì´ ìì ììë for...of
루í를 ì¬ì©íì¬ fruits
ë°°ì´ì ìííë©° ê° í목ì ì½ìì 기ë¡í©ëë¤.
const fruits = ["Apple", "Mango", "Cherry"];
for (const fruit of fruits) {
console.log(fruit);
}
// Apple
// Mango
// Cherry
ê·¸ë¬ë for...of
ë ë°°ì´ì ìííë ì¬ë¬ ê°ì§ ë°©ë² ì¤ íëì¼ ë¿ì
ëë¤. ë ë§ì ë°©ë²ì 루íì ìíì, every()
, filter()
, flatMap()
, map()
, reduce()
, reduceRight()
ë©ìëì ëí 문ì, ê·¸ë¦¬ê³ forEach()
ë©ìë를 ì¬ì©íë ë¤ì ìì를 참조íì¸ì.
ì´ ìì ë forEach()
ë©ìë를 ì¬ì©íì¬ fruits
ë°°ì´ì ê° ììì ëí´ í¨ì를 í¸ì¶í©ëë¤. ì´ í¨ìë ê° íëª©ì´ í목ì ì¸ë±ì¤ ë²í¸ë¥¼ í¨ê» ì½ìì 기ë¡í©ëë¤.
const fruits = ["Apple", "Mango", "Cherry"];
fruits.forEach((item, index, array) => {
console.log(item, index);
});
// Apple 0
// Mango 1
// Cherry 2
ì¬ë¬ ë°°ì´ ë³í©í기
ì´ ìì ë concat()
ë©ìë를 ì¬ì©íì¬ fruits
ë°°ì´ì moreFruits
ë°°ì´ê³¼ ë³í©í´ ìë¡ì´ combinedFruits
ë°°ì´ì ìì±í©ëë¤. fruits
ì moreFruits
ë ë³ê²½ëì§ ììµëë¤.
const fruits = ["Apple", "Banana", "Strawberry"];
const moreFruits = ["Mango", "Cherry"];
const combinedFruits = fruits.concat(moreFruits);
console.log(combinedFruits);
// ["Apple", "Banana", "Strawberry", "Mango", "Cherry"]
// 'fruits' ë°°ì´ì ë³ê²½ëì§ ììµëë¤.
console.log(fruits);
// ["Apple", "Banana", "Strawberry"]
// 'moreFruits' ë°°ì´ë ë³ê²½ëì§ ììµëë¤.
console.log(moreFruits);
// ["Mango", "Cherry"]
ë°°ì´ ë³µì¬í기
ì´ ìì ë 기존 fruits
ë°°ì´ìì ì ë°°ì´ì ë§ëë ì¸ ê°ì§ ë°©ë²ì ë³´ì¬ì¤ëë¤. 먼ì ì ê° êµ¬ë¬¸ì ì¬ì©íê³ , from()
ë©ìë, ê·¸ë¦¬ê³ slice()
ë©ìë를 ì¬ì©í©ëë¤.
const fruits = ["Strawberry", "Mango"];
// ì ê° êµ¬ë¬¸ì ì¬ì©íì¬ ë³µì¬ë³¸ì ë§ëëë¤.
const fruitsCopy = [...fruits];
// ["Strawberry", "Mango"]
// from() ë©ìë를 ì¬ì©íì¬ ë³µì¬ë³¸ì ë§ëëë¤.
const fruitsCopy2 = Array.from(fruits);
// ["Strawberry", "Mango"]
// slice() ë©ìë를 ì¬ì©íì¬ ë³µì¬ë³¸ì ë§ëëë¤.
const fruitsCopy3 = fruits.slice();
// ["Strawberry", "Mango"]
모ë ë´ì¥ ë°°ì´ ë³µì¬ ì°ì°(ì ê° êµ¬ë¬¸, Array.from()
, Array.prototype.slice()
, Array.prototype.concat()
)ì ìì ë³µì¬ë³¸ì ìì±í©ëë¤. ëì ë°°ì´ì ê¹ì ë³µì¬ë³¸ì ìíë¤ë©´ JSON.stringify()
를 ì¬ì©íì¬ ë°°ì´ì JSON 문ìì´ë¡ ë³íí ë¤ì, JSON.parse()
를 ì¬ì©íì¬ ë¬¸ìì´ì ìë ë°°ì´ê³¼ ìì í ë
립ë ì ë°°ì´ë¡ ë¤ì ë³íí ì ììµëë¤.
const fruitsDeepCopy = JSON.parse(JSON.stringify(fruits));
structuredClone()
ë©ìë를 ì¬ì©íì¬ ê¹ì ë³µì¬ë³¸ì ë§ë¤ ìë ìëë°, ì´ ë©ìëë ìì¤ì ì ì¡ ê°ë¥í ê°ì²´ë¥¼ ë¨ìí ë³µì íë ê²ì´ ìëë¼ ì ë³µì¬ë³¸ì¼ë¡ ì ì¡í ì ìë¤ë ì¥ì ì´ ììµëë¤.
ë§ì§ë§ì¼ë¡, 기존 ë°°ì´ì ì ë³ìì í ë¹í´ë ë°°ì´ì´ë ê·¸ ììì ë³µì¬ë³¸ì´ ìì±ëì§ ìëë¤ë ì ì ì´í´íë ê²ì´ ì¤ìí©ëë¤. ëì ì ë³ìë 기존 ë°°ì´ì ëí 참조 ëë ë³ì¹ì¼ ë¿ì´ë©°, 기존 ë°°ì´ì ì´ë¦ê³¼ ì ë³ì ì´ë¦ì ìì í ëì¼í ê°ì²´ì ëí ë ê°ì ì´ë¦ì¼ ë¿ì ëë¤(ë°ë¼ì íì ì격íê² ëì¼í ê²ì¼ë¡ íê°ë©ëë¤). ë°ë¼ì 기존 ë°°ì´ì ê°ì´ë ì ë³ìì ê°ì ì¡°ê¸ì´ë¼ë ë³ê²½íë©´, ë¤ë¥¸ ë³ìë ë³ê²½ë©ëë¤.
const fruits = ["Strawberry", "Mango"];
const fruitsAlias = fruits;
// 'fruits'ì 'fruitsAlias'ë ëì¼í ê°ì²´ì´ë©°, ì격íê² ëì¼í©ëë¤.
fruits === fruitsAlias; // true
// 'fruits' ë°°ì´ì ëí 모ë ë³ê²½ ì¬íì 'fruitsAlias'ë ë³ê²½í©ëë¤.
fruits.unshift("Apple", "Banana");
console.log(fruits);
// ['Apple', 'Banana', 'Strawberry', 'Mango']
console.log(fruitsAlias);
// ['Apple', 'Banana', 'Strawberry', 'Mango']
2ì°¨ì ë°°ì´ ë§ë¤ê¸°
ë¤ì ìì ë 2ì°¨ì 문ìì´ ë°°ì´ë¡ ì²´ì¤ íì ë§ëëë¤. 첫 ë²ì§¸ ì´ëì 'p'
ê° board[6][4]
ìì board[4][4]
ë¡ ë³µì¬ëì´ ì´ë£¨ì´ì§ëë¤. ì´ì ìì¹ [6][4]
ë ë¹ì¹¸ì´ ë©ëë¤.
const board = [
["R", "N", "B", "Q", "K", "B", "N", "R"],
["P", "P", "P", "P", "P", "P", "P", "P"],
[" ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " "],
["p", "p", "p", "p", "p", "p", "p", "p"],
["r", "n", "b", "q", "k", "b", "n", "r"],
];
console.log(`${board.join("\n")}\n\n`);
// í¹ì í°ì 2칸 ìì¼ë¡ ì´ë
board[4][4] = board[6][4];
board[6][4] = " ";
console.log(board.join("\n"));
ì¶ë ¥ ê²°ê³¼ì ëë¤.
R,N,B,Q,K,B,N,R P,P,P,P,P,P,P,P , , , , , , , , , , , , , , , , , , , , , , , , , , , , p,p,p,p,p,p,p,p r,n,b,q,k,b,n,r R,N,B,Q,K,B,N,R P,P,P,P,P,P,P,P , , , , , , , , , , , , , , , , , ,p, , , , , , , , , , p,p,p,p, ,p,p,p r,n,b,q,k,b,n,rë°°ì´ì ì¬ì©íì¬ ê° ì§í©ì íë¡ ë§ë¤ê¸°
const values = [];
for (let x = 0; x < 10; x++) {
values.push([2 ** x, 2 * x ** 2]);
}
console.table(values);
ì¶ë ¥ ê²°ê³¼ì ëë¤.
// 첫 ë²ì§¸ ì´ì ì¸ë±ì¤ì ëë¤. 0 1 0 1 2 2 2 4 8 3 8 18 4 16 32 5 32 50 6 64 72 7 128 98 8 256 128 9 512 162ì¼ì¹ 결과를 ì¬ì©íì¬ ë°°ì´ ë§ë¤ê¸°
RegExp
ì 문ìì´ ê°ì ì¼ì¹ ê²°ê³¼ë ì¼ì¹ì ëí ì 보를 ì ê³µíë ìì±ê³¼ ìì를 í¬í¨íë JavaScript ë°°ì´ì ìì±í ì ììµëë¤. ì´ë¬í ë°°ì´ì RegExp.prototype.exec()
ì String.prototype.match()
ìì ë°íë©ëë¤.
ì를 ë¤ì´ ë¤ìê³¼ ê°ìµëë¤.
// íëì d, íë ì´ìì b, íëì d를 ì¼ì¹ìíµëë¤.
// ì¼ì¹íë bì ë¤ë°ë¼ì¤ë d를 기ìµí©ëë¤.
// ëì문ìë 무ì.
const myRe = /d(b+)(d)/i;
const execResult = myRe.exec("cdbBdbsbz");
console.log(execResult.input); // 'cdbBdbsbz'
console.log(execResult.index); // 1
console.log(execResult); // [ "dbBd", "bB", "d" ]
ì¼ì¹ ê²°ê³¼ì ëí ìì¸í ë´ì©ì RegExp.prototype.exec()
ì String.prototype.match()
íì´ì§ë¥¼ 참조íì¸ì.
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