# 14. Rest parameters (가변 파라미터), 파라미터 갯수로부터 자유롭고 싶을때

😌 파라미터 갯수를 정하지 않고, 배열로 받고 싶을때.. 이걸 사용하면 되겠다!

# ✨ Rest parameters

every 는 전체 타입을 확인할 때 사용하면 유용하다!

function checkNum(...argArray) {  
  console.log(toString.call(argArray));
  console.log(argArray);
  
  const result = argArray.every((v) => typeof v === "number"); // 모든 값 type 확인
  console.log(result);
}

const result = checkNum(10,2,3,4,5,"55");

# 🔎 console


"[object Array]"
[10, 2, 3, 4, 5, "55"]
false

# Reference


https://www.inflearn.com/course/es6-강좌-자바스크립트/dashboard (opens new window)

https://jsbin.com/ (opens new window)

Last Updated: 3/8/2024, 5:46:31 AM