如何正确阅读EcmaScript规范 [英] How to properly read EcmaScript specification

查看:79
本文介绍了如何正确阅读EcmaScript规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对JavaScript二进制逻辑操作的如何工作知识感兴趣,但我仍然坚持步骤interpritation。

I'm interested in "HOW it work" knowledge for JavaScript binary logical operations, but I'm stuck at step interpritation.

所以这是对规范的描述


12.13.3



LogicalANDExpression:LogicalANDExpression && BitwiseORExpression

12.13.3

LogicalANDExpression: LogicalANDExpression && BitwiseORExpression


  1. lref 成为评估 LogicalANDExpression 的结果。

  2. lval 成为? GetValue lref )。

  3. lbool ToBoolean lval )。

  4. 如果 lbool 为false,返回 lval

  5. rref 成为评估 BitwiseORExpression 的结果。

  6. 返回? GetValue rref )。

  1. Let lref be the result of evaluating LogicalANDExpression.
  2. Let lval be ? GetValue(lref).
  3. Let lbool be ToBoolean(lval).
  4. If lbool is false, return lval.
  5. Let rref be the result of evaluating BitwiseORExpression.
  6. Return ? GetValue(rref).


我读过这就像:


  1. 为左操作数占用内存,这将是操作结果

  1. Take memory for left operand and here will be operation result

获取内存中左操作数的值并将其转换为布尔值

Get value of left operand in memory and convert it to boolean

如果此布尔值为false,则返回左操作数

if this boolean is false, return left operand

为右操作数占用内存,这将是...... BitwiseORExpression < - 什么?按位?为了什么?为什么?

我想以更易读的形式澄清这个算法以便理解这个怎么运作。什么是p.1和p.5,究竟是什么 lref rref ,究竟是什么 LogicalANDExpression BitwiseORExpression 在那个上下文中?

I'd would like to clarify this algorithm in more human-readable form for understanding how it works. What is p.1 and p.5, what really is lref and rref, what really is LogicalANDExpression and BitwiseORExpression in that context?

推荐答案

BitwiseORExpression 这里只是引用右侧操作数的(表达式) ,就像你正确推导出的那样, LogicalANDExpression 就是指左边的那个。它取决于你目前正在评估的代码(或者它的解析形式,AST),它可以是基本上任何东西并且不需要包含 | 运算符。

BitwiseORExpression here just refers to the (expression for the) right operand, exactly like LogicalANDExpression refers to the left one as you correctly deduced. What it is depends on the code (or rather its parsed form, the AST) that you are currently evaluating, it could be basically anything and does not need to contain an | operator.

这篇关于如何正确阅读EcmaScript规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆