0
我在下面有下面的代碼。我想訪問obj數組內的數組(名爲link1和link2)。對象數組中的返回數組元素
$(function() {
var storage = chrome.storage.local;
storage.clear();
var link1 = 'myLinks1';
var link2 = 'myLinks2';
var obj= {};
obj[link1] = ['www.google.com', 'yahoo.com', 'www.msn.com'];
obj[link2] = ['www.microsoft.com', 'live.com', 'www.espn.com'];
storage.set(obj);
storage.get(null,function(result){
//returns obj with array of links inside
console.log(result);
// Returns array of obj but doesn't contain array of links inside.
console.log(Object.keys(result));
});
});
編輯:我希望能夠訪問該鏈接,如www.Google.com
感謝
什麼_does_最後爲你輸出線路嗎?基於代碼,我希望它返回'[「myLinks1」,「myLinks2」]' –
'console.log(Object.keys(result).reduce(function(arr,k){return arr.concat(result [k])},[]));' – raina77ow