// 以下代码是否会正常执行,如果不会,如何改正
const [min, avg, max] = [100, 200, 300]
(function () {
console.log(min);
})()
const [min, avg, max] = [100, 200, 300];
(function () {
console.log(min);
})();
加上一个分号看看,输出结果 100
const [min, avg, max] = [100, 200, 300];
(function () {
console.log(min);
})();
JavaScript可以传任意个参数,也可以不传递参数。
参数是否存在的问题? 假设不存在参数,如何规避。
//手动抛出异常
if(typeof x !== ‘number’){
throw ‘Not a number’;
}