adding to json property that may or may not exist yet

前端 未结 8 2163
清酒与你
清酒与你 2021-01-04 04:12

let say I want to do this:

  var dashboard = {};
  var page = \"index\";

  $(\'.check\').click(function(){ 
    $(thi         


        
8条回答
  •  借酒劲吻你
    2021-01-04 04:41

    Well I guess you need this:

    var dashBoard = new Array();
    if(!dashboard['page123']) {
        dashBoard.push('page123');
    } else {
    ...do what you want
    }
    

    Seems you are dealing with XML.

提交回复
热议问题