[Javascript] Array.prototype.unshift()

Yuri Lee·2021년 11월 13일
0

Intro

리액트 관련 강의를 보다가 새로 알게 된 메서드를 소개하고자 한다.

Array.prototype.unshift()

unshift() 메서드는 새로운 요소를 배열의 맨 앞쪽에 추가하고, 새로운 길이를 반환한다.

Example

const array1 = [1, 2, 3];

console.log(array1.unshift(4, 5));
// expected output: 5

console.log(array1);
// expected output: Array [4, 5, 1, 2, 3

https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift

profile
Step by step goes a long way ✨

0개의 댓글