isNull (target) { if (typeof (target) === 'undefined' || target === null || target === '' || target === 'null' || target === 'undefined') { return true } else { return false } } /** * 加法运算 * * @param arguments 加数入参,个数不定 * @returns 和 */ adds () { let result = 0 let arrLength = [] let r1, m for (let item in arguments) { arguments[item] = this.isNull(arguments[item]) ? 0 : arguments[item] try { r1 = arguments[item].toString().split('.')[1].length } catch (e) { r1 = 0 } arrLength.push(r1) result += arguments[item] } m = Math.pow(10, Math.max.apply(null, arrLength)) return (result * m) / m }
使用说明:
adds(RC1, RC2)