标签:arguments function UNC ons amp += type ++ for
function sum() { let num = 0; for (let i = 0; i < arguments.length; i++) { //注意:typeof(NaN) => ‘number‘,但是 (NaN === NaN) => false if (typeof (arguments[i]) === ‘number‘ && parseFloat(arguments[i]) === parseFloat(arguments[i])) { num += arguments[i] } } return num } console.log(sum(1, 2.5, 3.8, ‘2px‘, 54, true, ‘‘, function () {}, {}, ‘2‘, NaN, -1 )); //61.3
标签:arguments function UNC ons amp += type ++ for
原文地址:https://www.cnblogs.com/MrZhujl/p/13174225.html