名称之前不能让-TypeError:name.map不是函数

问题描述

如果在分配给变量let之前不使用varname,则会收到 TypeError:name.map不是函数 是保留字或其他名称。如果是这样,我想知道为什么在分配name = [ ... ];中没有出现任何错误
谁能给我更多有关此行为的信息。

name = ["apple","orange","strawBerry","banana"];
result = name.map(elem => elem.toupperCase() );
console.log(result);

如果我将let或var放到需要的位置。

let name = ["apple","banana"];
result = name.map(elem => elem.toupperCase() );
console.log(result);

尽管所有其他变量名通常都可以避免,但全局使用它没有任何问题。

other = ["apple","banana"];
result = other.map(elem => elem.toupperCase() );
console.log(result);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)