简体   繁体   English

ECMAScript(ECMA-262 5.1)中`reference`的“基本值”是什么?

[英]What is `base value` of `reference` in ECMAScript(ECMA-262 5.1)?

I've been trying to understand how this value is set in javascript, and found ECMAScript Language Specification pretty much helpful. 我一直试图了解如何在javascript中设置this值,并发现ECMAScript语言规范非常有用。 I was reading section 8.7 reference specification type and found that reference in ECMAScript is made of 3 component, base value , referenced name , strict reference flag to understand section 11.2.3 . 我正在阅读第8.7节的 reference specification type ,发现ECMAScript中的引用由3个组件, base valuereferenced namestrict reference flag以理解第11.2.3节

I can assume what are referenced name and strict reference flag from their name, but i don't understand what is the base value . 我可以从他们的名字中假设referenced namestrict reference flag ,但我不明白什么是base value The document says that base value is either undefined , String , Boolean , Number and Object , but it does not say how it is set and what it is. 该文档说base valueundefinedStringBooleanNumberObject ,但它没有说明它是如何设置的以及它是什么。 I am guessing it is something similar to context object. 我猜这是类似于上下文对象的东西。 Could anyone explain? 谁能解释一下?

Yes, the base value is the context in which the referenced name lives. 是的, 基值是引用名称所在的上下文。

For an object property, this would be the object (see §8.12 Object internal methods for setter/getter operations). 对于对象属性,这将是对象(参见§8.12用于setter / getter操作的对象内部方法 )。 For a variable, this would be the variable environment ( §10.2.1 Environment records ). 对于变量,这将是变量环境(第10.2.1节环境记录 )。 For an unresolvable reference (the things that throw reference errors except when supplied to typeof ), this would be undefined . 对于不可解析的引用( 除了提供给typeof抛出引用错误的东西),这将是undefined

it does not say how it is set 它没有说明它是如何设置的

Reference values are only constructed by very few operations: Reference值仅由极少数操作构成:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM