1. Javascript
const arr = [1, 2, 3, 4, 5];
const maxValue = Math.max(...arr);
const minValue = Math.min(...arr);

Spread Operator(전개 연산자)는 ES6 문법이며, '...' 점 3개로 표현, 객체나 배열의 원소들을 하나씩 꺼내어서 리턴한다. 즉, Math.max(...arr)와 같이 작성해주면 실제로는
Math.max(1, 2, 3, 4, 5)와 같이 실행된다.

const arr = [1, 2, 3];

arr.splice(1, 1);    
console.log(arr);    => [1, 3] 출력

splice(시작지점, 삭제할 요소 개수)

profile
이동은

0개의 댓글