Example #1
0
        private static ScriptValue GetOwnPropertyDescriptor([NotNull] ScriptArguments arg)
        {
            //https://tc39.github.io/ecma262/#sec-reflect.getownpropertydescriptor
            if (!arg[0].IsObject)
            {
                throw arg.Agent.CreateTypeError();
            }

            var key        = arg.Agent.ToPropertyKey(arg[1]);
            var descriptor = ((ScriptObject)arg[0]).GetOwnProperty(key);

            return(ObjectIntrinsics.FromPropertyDescriptor(arg.Agent, descriptor));
        }
Example #2
0
        private static ScriptValue DefineProperty([NotNull] ScriptArguments arg)
        {
            //https://tc39.github.io/ecma262/#sec-reflect.defineproperty
            if (!arg[0].IsObject)
            {
                throw arg.Agent.CreateTypeError();
            }

            var key        = arg.Agent.ToPropertyKey(arg[1]);
            var descriptor = ObjectIntrinsics.ToPropertyDescriptor(arg.Agent, arg[2]);

            return(((ScriptObject)arg[0]).DefineOwnProperty(key, descriptor));
        }