Alternative version for Object.values()

前端 未结 11 1723
花落未央
花落未央 2020-11-28 06:13

I\'m looking for an alternative version for the Object.values() function.
As described here the function is not supported in Internet Explorer.

When

11条回答
  •  一生所求
    2020-11-28 07:07

    You can get array of keys using Object.keys(). This will work in IE also. Object.values() is not required at all to get values since we can use the keys obtained from Object.keys() to get values as below:

    var obj = { foo: 'bar', baz: 42 };
    var keyArray = Object.keys(obj);
    for(var i = 0; i < keyArray.length; i++)
        console.log(obj[keyArray[i]]); 
    

提交回复
热议问题