unexpected token break in ternary conditional

前端 未结 2 1797
别跟我提以往
别跟我提以往 2021-01-27 05:08

The function below is intended to return the values from a (potentially nested) object as an array - with the list parameter being any object. If I move my break statement to af

2条回答
  •  无人及你
    2021-01-27 05:41

    why not writing something like this :

    var obj = { 0: "a", 1: "b", 2: "c"}; //test target
    var objectArray = [];
    var keyArray = Object.getOwnPropertyNames(obj);
    for (var i = 0; i < keyArray.length; i++)  objectArray.push(obj[keyArray[i]]);
    console.log(objectArray);  // test result
    

提交回复
热议问题