js取对象中的键与值

const data = {
  one: 'first',
  two: 'second',
  three: 'third'
}

for (var i in data) {
  console.log('键:' + i)
  console.log('值:' + data[i])
}

结果是:

猜你喜欢

转载自blog.csdn.net/qq_32678401/article/details/81704705
今日推荐