How to list the properties of a JavaScript object?

后端 未结 17 2607
刺人心
刺人心 2020-11-22 00:34

Say I create an object thus:

var myObject =
        {\"ircEvent\": \"PRIVMSG\", \"method\": \"newURI\", \"regex\": \"^http://.*\"};

What is

17条回答
  •  星月不相逢
    2020-11-22 01:29

    Building on the accepted answer.

    If the Object has properties you want to call say .properties() try!

    var keys = Object.keys(myJSONObject);
    
    for (var j=0; j < keys.length; j++) {
      Object[keys[j]].properties();
    }
    

提交回复
热议问题