Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
221 views
in Technique[技术] by (71.8m points)

javascript - 我听不懂这部分:“(obj [val] || 0)+1;” [重复](I can't understand this part: “(obj[val] || 0)+1;” [duplicate])

 let arr = [1, 2, 3, 2, 3], obj = {}; for (let val of arr) { obj[val] = (obj[val] || 0) + 1; } console.log(obj); 

Output should be:

(输出应为:)

obj = {
  1: 1,
  2: 2,
  3: 3
}
  ask by Karunamay Murmu translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...