Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.dynjs.runtime.builtins.types.object;
 
public class Freeze extends AbstractNativeFunction {
    public Freeze(GlobalObject globalObject) {
        super(globalObject"o");
    }
    @Override
    public Object call(ExecutionContext contextObject selfObject... args) {
        // 15.2.3.9
        Object o = args[0];
        if (!(o instanceof JSObject)) {
            throw new ThrowException(contextcontext.createTypeError("must be an object"));
        }
        JSObject jsObj = (JSObjecto;
        NameEnumerator names = jsObj.getOwnPropertyNames();
        
        while (names.hasNext()) {
            String name = names.next();
            Object d = jsObj.getOwnProperty(contextname);
            if (d != .) {
                PropertyDescriptor desc = (PropertyDescriptord;
                if (desc.isDataDescriptor()) {
                    Object isWritable = desc.get("Writable");
                    if (isWritable == .) {
                        desc.set("Writable"false);
                    }
                }
                Object isConfigurable = desc.get("Configurable");
                if (isConfigurable == .) {
                    desc.setConfigurable(false);
                }
                jsObj.defineOwnProperty(contextnamedesctrue);
            }
        }
        jsObj.setExtensible(false);
        return jsObj;
    }
New to GrepCode? Check out our FAQ X