8.1.1.4.18 CreateGlobalFunctionBinding ( N, V, D )
用于全局环境记录的具体环境记录方法 CreateGlobalFunctionBinding 在关联对象 Environment Record 中创建并初始化可变绑定,并在关联的 [[VarNames]] 列表中记录绑定名称。 如果绑定已存在,则替换它。
- 使 envRec 变为调用该方法的全局环境记录。
- 使 ObjRec 变为 envRec.[[ObjectRecord]].
- 使 globalObject 变为 ObjRec 的绑定对象。
- 使 existingProp 变为 ? globalObject.[[GetOwnProperty]](N)。
- 如果 existingProp 为 undefined 或 existingProp.[[Configurable]] 为 true,,那么
a. 使 desc 变为 PropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: D}。
6.否则,
a. 使 desc 变为 PropertyDescriptor{[[Value]]: V }。
7.执行? DefinePropertyOrThrow(globalObject, N, desc)。
8.记录 ObjRec中 N 的绑定已初始化。
9.执行 ? Set(globalObject, N, V, false)。
10.使 varDeclaredNames 变为 envRec.[[VarNames]]。
11.如果 varDeclaredNames 不包含 N,那么
a. 添加 N 到 varDeclaredNames 上。
12.返回 NormalCompletion(empty)。