編寫一個名為 myFun 的函數(shù),該函數(shù)將一個對象作為其參數(shù),并在數(shù)組中返回該對象的屬性名稱。例如,如果它接收到 {a:1,b:3} 作為參數(shù),它應(yīng)該返回 [a, b],或者如果它接收到 {u:4, k:3, h:5},它應(yīng)該返回[你,k,h]。注意我知道 Object.Keys(object) 返回 ['a', 'b', 'c']//this function should return the name of the propertyfunction myFun(object) { object = { a: 1, b: 2, c: 3 } for (obj in object) { console.log(obj); }} myFun();//testcase : console.log(myFun({a:6})[0]) which should return [a], is it actually possible or am I asking the wrong question?
是否可以返回帶有對象屬性名稱的數(shù)組?它有線要求打印沒有''的字符串
函數(shù)式編程
2023-05-25 18:16:14