错误
1、
Uncaught TypeError: Cannot set properties of null (setting ‘innerHTML’)
改错
错误的原因:js中代码执行遵循从上到下的原则,获取标签的代码写在了把标签声明之前,导致获取失败报错。将获取代码写在声明之后,运行成功。
参考:https://stackoverflow.com/questions/18239430/cannot-set-property-innerhtml-of-null
2、
错误:
01-网页时钟(图形版).html:76 Uncaught TypeError: Cannot read properties of null (reading ‘style’)
原因:
获取元素的时候,css类选择器忘记写.
改正:
3
// 下面res的返回值是[2] 说法对吗
const arr = [1,2,3]
const res = arr.map(function(item, index) {
return item % 2 === 0
})
console.log(res);
答案: 不对返回结果是数组:[false, true, false]
4
// 下面res的返回值是 undefined 说法对吗
const arr = [11, 22, 33, 44]
const res = arr.find(item => item > 50)
console.log(res);
对
5