问题:我似乎无法找到一个令人满意的解释,为什么javascript Maps需要使用方括号来使JSON.stringify方法"到达"(?)到嵌套元素中.我想我错过了关于ES6的一些东西,或Map数据类型固有的东西.
我可以将Map转换为对象,并使用stringify-但为什么这个额外的步骤是必要的?
我的实验:
const blah = new Map();
blah.set('u', {
'something': [{'hey':98}, 56, 'bob']
});
blah.set({
'hey': {'hey': 78}
}, 'what?');
console.log(JSON.stringify(...blah));
//["u",{}]
//I thought this would yield the result of the below console.log
console.log(JSON.stringify([...blah]))
//[["u",{"something":[{"hey":98},56,"bob"]}],[{"hey":{"hey":78}},"what?"]]
//Why are the square brackets needed to stringify and display each element of
//the map?
Run Code Online (Sandbox Code Playgroud)
这条确认的行为,但并没有解释为什么会发生.
我认为这是一个简单的修复。
当我print(Bundle.main.localizations),
我得到:
["de", "ar", "en", "es", "it", "Base", "fr", "pt-PT"]
但是,我最近删除了阿拉伯字符串文件并从项目中删除了本地化:
如何删除作为本地化之一的阿拉伯语?从用户的角度来看,我不确定这种情况的后果,并且不希望 iTunesConnect/AppStore 发生任何奇怪的事情,例如以某种方式宣传有可用的阿拉伯语本地化,而实际上没有。
brackets ×1
ecmascript-6 ×1
ios ×1
javascript ×1
json ×1
localization ×1
stringify ×1
xcode ×1