Javascript将Array中的特定ID值提取到另一个Array

Ron*_*rio 2 javascript arrays jquery local-storage

我在脚本上有结果数组,如下所示:

var myurlsave = [{"url_field":"yahoo","enabled":true},{"url_field":"google","enabled":true},{"url_field":"bing","enabled":true}];
Run Code Online (Sandbox Code Playgroud)

我想将它提取为如下所示:

var myurlname = ["yahoo", "google", "bing"];
Run Code Online (Sandbox Code Playgroud)

我认为这对你来说很容易,但我很难做到这一点.谢谢您的帮助

Wil*_*ese 5

var arr = myurlsave.map(function(a) {
    return a.url_field;
});
Run Code Online (Sandbox Code Playgroud)

  • 供参考:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map?v = control (2认同)