Math.min(1,2,3,4,5)
-> 1이 나올 것이다.
Math.max(1,2,3,4,5,)
그러면 배열에 속해있는 수의 최소,최대값을 구해보자
const nums=[1,2,3,4,5,6]
Math.max(nums)
-> undefined가 나온다.
왜그럴까?
바로 현재 nums는 숫자가 아닌 배열이기 때문이다. 따라서 배열을 숫자로 변환을 시켜줘야한다.
nums = [1,2,3,4,5,6]
...nums = 1,2,3,4,5,6 이 되어버린다.
console.log('hello')
-> hello
console.log(...'hello')
-> h e l l o
console.log(...'h','e','l')
-> h e l
문자열 한덩어리가 문자 하나씩 분리가 되었습니다.