JavaScript:好的部件名称/字符串铁路图令人困惑 [英] JavaScript: The Good Parts Names/Strings railroad diagrams confusing

查看:97
本文介绍了JavaScript:好的部件名称/字符串铁路图令人困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始阅读JavaScript:好的零件书,并在第一页(如果确切地说是7和9)被铁路图弄糊涂了。

I started reading JavaScript: The Good Parts book and became confused at first pages (7 and 9 if be exact) by the railroad diagrams.

有图表名称和字符串文字。 (您可以在此处查看图表)

There are diagrams for the name and the string literal. (you can see the diagrams here)

我知道JavaScript中的名字可以以字母开头,也可以以下划线或$符号开头。按照本书的图表,它只能从字母开始。

As I know names in JavaScript can start with letters as well as with underscore or even '$' symbol. Following by the book's diagram it can starts only from letters.

对于字符串文字,假设您想要表示字符串:\\。< br>
按照图表后面是不可能的(似乎在转义字符之后,除了之外的任何unicode字符,并且需要\和contol。

For the string literal, imagine that you want to represent string like that: "\\".
Following by the diagram it's not possible(seems like after the "escaped character" the "any unicode character except " and \ and contol" is required.

这些是书中的错误吗?或者我错过了什么?

Are those an errors in the book? Or I miss something?

推荐答案

善良一书中描述的语言部件不是JavaScript而是它的一部分 - 你可以称之为Crockford的JavaScript.Crockford引入了新的语法限制。其中一个限制是名称不能以 $ 开头或 _

The language described in the book "The Good Parts" is not JavaScript but a subset of it - you can call it "Crockford's JavaScript". Crockford introduces new syntax restrictions. One of those restrictions is that names cannot start with $ or _.

这篇关于JavaScript:好的部件名称/字符串铁路图令人困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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