Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.dynjs.runtime.builtins.types.object;
 
public class GetOwnPropertyNames extends AbstractNativeFunction {
    public GetOwnPropertyNames(GlobalObject globalObject) {
        super(globalObject"o");
    }
    @Override
    public Object call(ExecutionContext contextObject selfObject... args) {
        // 15.2.3.4
        Object o = args[0];
        if (!(o instanceof JSObject)) {
            throw new ThrowException(contextcontext.createTypeError("must be an object"));
        }
        JSObject jsObj = (JSObjecto;
        JSObject array = BuiltinArray.newArray(context);
        int i = 0;
        NameEnumerator names = jsObj.getOwnPropertyNames();
        while (names.hasNext()) {
            final String name = names.next();
            array.defineOwnProperty(context"" + inew PropertyDescriptor() {
                {
                    set("Value"name);
                    set("Writable"true);
                    set("Configurable"true);
                    set("Enumerable"true);
                }
            }, false);
            ++i;
        }
        return array;
    }
New to GrepCode? Check out our FAQ X