자바스크립트/모던 자바스크립트
모던 자바스크립트, 단축 속성 (shorthand properties)
Jake Seo
2023. 1. 24. 23:58
단축 속성 (shorthand properties)
단축 속성 (shorthand properties)
은 프로퍼티의 키와 값이 동일할 때 키만 적어도 같은 이름의 변수 값을 값 영역으로 끌어온다.
예제
function getMinMax(nums) {
const min = Math.min(...nums);
const max = Math.max(...nums);
return { min, max };
}
getMinMax([1, 2, 3]); // {min: 1, max: 3}
반응형