Friday, December 16, 2022

Arguments Exotic Objects

Arguments Exotic Objects

Most ECMAScript functions make an arguments object available to their code. Depending upon the characteristics of the function definition, its arguments object is either an ordinary object or an arguments exotic object.

An arguments exotic object is an exotic object whose array index properties map to the formal parameters bindings.

Arguments exotic objects have a [[ParameterMap]] internal slot. Ordinary arguments objects also have a [[ParameterMap]] internal slot whose value is always undefined.

[[GetOwnProperty]] ( P )

  1. Let args be the arguments object.
  2. Let desc be OrdinaryGetOwnProperty(args, P).
  3. If desc is undefined, return desc.
  4. Let map be args.[[ParameterMap]].
  5. Let isMapped be HasOwnProperty(map, P).
  6. If isMapped, set desc.[[Value]] to Get(map, P)
  7. Return desc.

[[DefineOwnProperty]] ( P, Desc )

  1. Let newArgDesc be Desc.
  2. If isMapped and Desc.[[Value]] is not present and Desc.[[Writable]] is false,
        Set newArgDesc to a copy of Desc except newArgDesc.[[Value]] as Get(map, P)
        
  3. if not OrdinaryDefineOwnProperty(args, P, newArgDesc), return false.
  4. If isMapped is false, return true
  5. If IsAccessorDescriptor(Desc), call map.[[Delete]](P) and return true
  6. If Desc.[[Value]] is present, Set(map, P, Desc.[[Value]], false).
  7. If Desc.[[Writable]] is false, Call map.[[Delete]](P)

No comments:

Post a Comment