如图,此段代码在vscode的控制台里运行出了正确的结果
结果当我放到项目里时
arr[dimension].dimension_level.forEach(item => res.push(item.level_name), res = [])
console.log(res);
已经确认arr[dimension].dimension_level
值为正确的数组值,但是浏览器控制台报错
Uncaught ReferenceError: res is not defined
at handleOk (http://localhost:8989/0.5ff4e4c1c3a9ca506801.hot-update.js:153:25)
浏览器为chrome,操作系统为mac,
can i use 里foreach的兼容性是一片绿,我不知道哪里出问题了,最神奇的是我好像没做啥改变,有一次是没报错打印出了正确的结果的,好像没改啥又报错了
有定义
res
么,可能一个是严格模式一个是非严格模式吧。