📎아이템 31 타입 주변에 null 값 배치하기
📍 null 값 배치의 필요성
📍예제
🔗 숫자들의 최솟값과 최댓값을 계산하는 extent 함수
// @strictNullChecks: false
function extent(nums: Iterable<number>) {
let min, max;
for (const num of nums) {
if (!min) {
min = num;
max = num;
} else {
min = Math.min(min, num);
max = Math.max(max, num);
}
}
return [min, max];
}📍요약
Last updated