javascript中的java关键字

发布于 2024-11-06 07:40:21 字数 309 浏览 1 评论 0原文

根据这个页面 http://www.quackit.com/javascript/javascript_reserved_words.cfm javascript有一些来自java的关键字,保留。我还注意到编辑器中的突出显示。这是为了未来的证明吗?他们是否计划在 JavaScript 中实现更多 OOP 风格的运算符?

我很想在 js 中看到接口、抽象类和类似的东西,但是这些词的保留是否表明了什么?

according to this page
http://www.quackit.com/javascript/javascript_reserved_words.cfm
javascript has some keywords which are from java, reserved. I also notice that with the highlighting in my editor. Is this to be future proof? Are they planning to implement some more OOP style operators into javascript?

I would love to se interfaces, abstract classes and things like that coming to js, but does the reservation of these words indicate anything?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

当爱已成负担 2024-11-13 07:40:22

来自 ECMA-262 规范,§7.6.1.2 (未来保留字):

ecmascipt 部分截图

并且,来自 §2 (一致性):

允许 ECMAScript 的一致实现支持本规范中未描述的程序和正则表达式语法。特别是,允许​​ ECMAScript 的一致实现支持使用本规范 7.6.1.2 中列出的“未来保留字”的程序语法。

From the ECMA-262 spec, §7.6.1.2 (Future Reserved Words):

ecmascipt section screenshot

And, from §2 (Conformance):

A conforming implementation of ECMAScript is permitted to support program and regular expression syntax not described in this specification. In particular, a conforming implementation of ECMAScript is permitted to support program syntax that makes use of the "future reserved words" listed in 7.6.1.2 of this specification.

万劫不复 2024-11-13 07:40:22

保留这些词只是为了向原作者 (Brendan Eich) 提供构建关键字的起点。

另外,JavaScript的设计
符合Java的语法和标准
图书馆在心中。特别是,所有
Java 关键字被保留在
原始 JavaScript,JavaScript 的
标准库遵循Java的命名
约定,以及 JavaScript 的数学和
日期对象基于来自
Java 1.0

“JS 必须“看起来像 Java”,只是不那么重要,成为 Java 的愚蠢弟弟或男孩人质伙伴。另外,我必须在十天内完成,否则会发生比 JS 更糟糕的事情” — 布伦丹·艾奇

目前没有计划将特定的 Java 功能集成到 Javascript 中。 当前路线图建议了以下功能:

  • 模块系统
  • 可选类型注释和静态类型,可能使用结构类型系统
  • 生成器和迭代器
  • 解构
  • 赋值 代数数据类型

The words are reserved only to offer the original author (Brendan Eich) a starting point on which to build keywords.

In addition, JavaScript was designed
with Java's syntax and standard
library in mind. In particular, all
Java keywords were reserved in
original JavaScript, JavaScript's
standard library follows Java's naming
conventions, and JavaScript's Math and
Date objects are based on classes from
Java 1.0
.

"JS had to “look like Java” only less so, be Java’s dumb kid brother or boy-hostage sidekick. Plus, I had to be done in ten days or something worse than JS would have happened" — Brendan Eich

There are currently no plans to integrate specific Java features into Javascript. The current roadmap suggests these features:

  • Classes
  • A module system
  • Optional type annotations and static typing, probably using a structural type system
  • Generators and iterators
  • Destructuring assignment
  • Algebraic data types
梦纸 2024-11-13 07:40:22

不,他们不保证任何事情,他们最初是为了“以防万一”而保留的,从那时起就一直保留在该语言中。它们可能会也可能不会被使用,但大多数在不久的将来不会被使用。

No they don't guarantee anything, they were originally reserved "just in case" and have stuck in the language since then. They may or may not get used but most will not be used in the near future.

蓝戈者 2024-11-13 07:40:22

@Andy 和 @OriginalSyn 已经回答了你的问题,我只想回答这个问题:

我很想在 js 中看到接口、抽象类和类似的东西,但是这些词的保留是否表明了什么?

这些结构不太可能出现在 JavaScript 中。 JS 遵循基于原型 OOP 模型,不使用类之类的东西。与经典的基于类的模型相比,该模型具有一些优势,您必须喜欢它,否则就停止使用 JS,因为这种语言没有真正的替代品。 ;)

@Andy and @OriginalSyn already answered your question and I just wanted to answer to this:

I would love to se interfaces, abstract classes and things like that coming to js, but does the reservation of these words indicate anything?

It's very unlikely that these constructions have ever appear in JavaScript. JS follows prototype-based OOP model which doesn't use things like classes. This model has some advantages over classical, class-based model and you'll have to love it or stop using JS as there is no real alternative for this language. ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文