1. const obj = { name: 'Daniel', age: 40, occupation: 'Engineer', level: 4 };
  2. console.log(Object.keys(obj));
  3. // Expected output: ["name", "age", "occupation", "level"]
  4. console.log(Object.values(obj));
  5. // Expected output: ["Daniel", 40, "Engineer", 4]
  6. console.log(Object.entries(obj));
  7. // Expected output: [["name", "Daniel"], ["age", 40], ["occupation", "Engineer"], ["level", 4]]

参考

JavaScript - How to Get an Object’s Keys and Values in JavaScript