2016-09-21 63 views

回答

0

您可以使用多個途徑爲鍵值對

  1. 迭代在Loop

    的(在validation_messages VAR鍵){

    if (!validation_messages.hasOwnProperty(key)) continue; 
    
    var obj = validation_messages[key]; 
    for (var prop in obj) { 
        // skip loop if the property is from prototype 
        if(!obj.hasOwnProperty(prop)) continue; 
    
        // your code 
        console.log(prop + " = " + obj[prop]); 
    } 
    

    }

  2. 地圖 https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Map