【发布时间】:2020-12-12 15:34:49
【问题描述】:
我想比较同一个数组中的元素来得到这个结果
let arr = ['one','two','three','four'];
arr.forEach((ele, i, ar)=>{
console.log(ele, i, ar)
for(let item = i; item< ar.length; item++ ){
console.log (ele, ar[item])
}
})
'one' => 'two',
'one' => 'three',
'one' => 'four',
'two' => 'three',
'two' => 'four',
'three' => 'four'.
【问题讨论】:
-
您对此有何疑问?
-
发帖前先研究一下,这是重复的。
标签: javascript arrays angular for-loop string-literals