var amaList = ['announce', 'argue', 'demonstrate', 'express', 'hint', 'illustrate', 'imply', 'make', 'mean', 'pinpoint', 'point out', 'prove', 'reveal', 'show', 'signal', 'specify', 'suggest', 'attest', 'connote', 'denote', 'designatesta']
var hintList = amaList.forEach(function(s) {
return s
})
console.log(hintList)
hintList
记录undefined
我做错了什么?
答案 0 :(得分:1)
您可能想要使用Array.prototype.map:
var hintList = amaList.map(function(item) {
//do something with item and return the wanted item
});
Array.prototype.forEach不返回任何内容。
以下是使用forEach的示例:
amaList.forEach(function(item){
console.log(item);
});