标题如上
function abs(x) { if (typeof x !== 'number') { throw 'Not a number';
加了一个防错,求绝对值要保证输入的参数是数字,所以if判断参数的数据类型是不是数字,不是的话直接返回“不是数字”,是的话继续执行下面的内容
这个“throw"是不是理解成”return“就行了?
Sign in to make a reply
彻
标题如上