-
[JavaScript] arguments컴퓨터/JavaScript_typescript 2020. 10. 4. 14:40728x90
* arguments
* the arguments object does not exist inside arrow functions, only traditional ones.
화살표 함수에서는 arguments를 사용할 수 없다.
* The arguments object returns an array-like list of the arguments that are passed into a function.
=> arguments는 array의 prototype을 상속하지 않는다
var maxOfThree = function () { // If there's more than three arguments if (arguments.length > 3) { throw new Error('A max of three parameters are allowed.'); } // Run the Math.max() method, with the arguments passed in return Math.max.apply(null, arguments); };
함수 body block 안에서 매개변수에 접근할 수 있다.
Note : rest 연산자로 정의한 parameter는 배열이다. array의 prototype을 상속한다.
반응형'컴퓨터 > JavaScript_typescript' 카테고리의 다른 글
<script> 태그를 어디에 둘까, async, defer (0) 2020.12.11 [JavaScript] 같음 비교 (0) 2020.10.05 [ JavaScript ] Currying 함수 (0) 2020.09.15 [JavaScript] disable right click (0) 2020.06.10 [JavaScript] textContent, innerHTML, innerText (0) 2020.04.07