📜  返回对象的键和值 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:32.755000             🧑  作者: Mango

代码示例1
const keysAndValues = (obj) => [Object.keys(obj), Object.values(obj)];

keysAndValues({a: 1, b: 2, c: 3}); 
//➞ [["a", "b", "c"], [1, 2, 3]]

keysAndValues({a: "Dell", b: "Microsoft", c: "Google"}));
//➞ [["a", "b", "c"], ["Dell", "Microsoft", "Google"]]

keysAndValues({key1: true, key2: false, key3: undefined});
// ➞ [["key1", "key2", "key3"], [true, false, undefined]]