On Jun 14, 2012, at 10:22 AM, Brendan Eich wrote:
> Hemanth H.M wrote:
>> var info = { name: "Hemanth", url: "http://h3manth.com/", location :
>> "Earth", get : function() {} };
>> Object.keys(info)
>> ["name", "url", "location", "get"]
>>
>> Now, it's not clear about the 'type' of the keys; name is a String, where as
>> get is a function.
>>
>> Compared to something like inspect module in python that give o/p like :
>>
>> ('__delslice__', <method-wrapper '__delslice__' of list object at
>> 0x1005252d8>)
>
> Python's repr convention is missed in JS, but instead of trying to force
> everything into a standard string representation, how about just building on
> ES5 (already mailed to you, sharing with list here):
>
> js> o = {p:1, q:2, get r(){return 3}}
> ({p:1, q:2, get r () {return 3;}})
> js> function inspect(o) {
> var a = [];
> Object.getOwnPropertyNames(o).forEach(function (k) {
> a.push(Object.getOwnPropertyDescriptor(o, k));
You probably want to make the above line:
a.[k] = Object.getOwnPropertyDescriptor(o,k}
This should give you a descriptor that can be passed back into
Object.defineProperties
Also initialize a to { }.
Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss