Hi FE !
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
  • Object.fromEntries()

Object.fromEntries()

// 假设后端返回的用户信息是键值对数组
const userArray = [
  ["name", "qdleader"],
  ["age", 28],
  ["email", "tom@example.com"],
];
// 使用Object.fromEntries()将键值对数组转为对象
const userObject = Object.fromEntries(userArray);
console.log(userObject);
// {name: 'qdleader', age: 28, email: 'tom@example.com'}
Edit this page
最近更新: 2025/10/17 02:02
Contributors: qdleader
qdleader
本站总访问量 129823次 | 本站访客数 12人