js字典


1、遍歷

var json={
    "name":"喬峰",
    "age":"10",
    "sex":""
};
for(var key in json){
    console.log(key+":"+json[key]);
}

 2、通過下表獲取

var ViewType =
{
    a: "a",
    b: "b", 
    c: "c" 
};
var keys = Object.keys(ViewType)
var values = Object.values(ViewType)
console.log(keys[1] + ':' + values[1])

 此字典無法在QML中聲明,不然會報錯: javascript declaration outside script element


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM