How to list the properties of a JavaScript object?

后端 未结 17 2577
刺人心
刺人心 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:23

    Note that Object.keys and other ECMAScript 5 methods are supported by Firefox 4, Chrome 6, Safari 5, IE 9 and above.

    For example:

    var o = {"foo": 1, "bar": 2}; 
    alert(Object.keys(o));
    

    ECMAScript 5 compatibility table: http://kangax.github.com/es5-compat-table/

    Description of new methods: http://markcaudill.com/index.php/2009/04/javascript-new-features-ecma5/

提交回复
热议问题