不积跬步,无以至千里。

我的学习笔记

首页

空明百问

web综合

内容更新于: 2022-09-20 09:09:52

reduce_parseInt

前言:数组的几个问题。[].reduce(Math.pow);输出什么?parseInt

1.reduce


console.log([1,2,3].reduce(Math.pow));
console.log([].reduce(Math.pow));


结果: [console 1]: 1 [console 2]: 报错 Uncaught TypeError: Reduce of empty array with no initial value

2.parseInt


console.log([1,2,3].map(parseInt));


结果: [console 1]: [1, NaN, NaN]

3.typeof & instanceof


console.log(typeof null);
console.log(null instanceof Object);


结果: [console 1]: Object [console 2]: false

4.getPrototypeOf


function f () {}
const a = f.prototype;
const b = Object.getPrototypeOf(f);
console.log(a === b);


结果: [console 1]: false

本文结束