Alternative version for Object.values()

前端 未结 11 1730
花落未央
花落未央 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 06:57

    Object.values() is part of the ES8(June 2017) specification. Using Cordova, I realized Android 5.0 Webview doesn't support it. So, I did the following, creating the polyfill function only if the feature is not supported:

    if (!Object.values) Object.values = o=>Object.keys(o).map(k=>o[k]);
    

提交回复
热议问题