美文网首页
ES2017 - Object.entries

ES2017 - Object.entries

作者: 盖伦_2985 | 来源:发表于2020-08-23 15:53 被阅读0次
    const numbers = {
      one: 1,
      two: 2
    }
    Object.entries(numbers);
    // [ ['one', 1], ['two', 2] ]
    
    const numbers = {
      one: 1
    };
    const objectArray = Object.entries(numbers);
    objectArray.forEach(([key, value]) => {
      console.log(key);     // 'one'
      console.log(value);   // 1
    })
    

    相关文章

      网友评论

          本文标题:ES2017 - Object.entries

          本文链接:https://www.haomeiwen.com/subject/xznxkktx.html