JavaScript

JavaScript (JS) 是一种带有 first-class functions 的轻量级解释型(或 实时 编译型)编程语言。虽然它是最著名的网页脚本语言,但 许多非浏览器环境 也使用它,例如 Node.jsApache CouchDBAdobe Acrobat。JavaScript 是一种 基于原型、多范式、单线程动态 语言,支持面向对象、命令式和声明式(例如函数式编程)风格。

¥JavaScript (JS) is a lightweight interpreted (or just-in-time compiled) programming language with first-class functions. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.js, Apache CouchDB and Adobe Acrobat. JavaScript is a prototype-based, multi-paradigm, single-threaded, dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles.

JavaScript 的动态功能包括运行时对象构造、可变参数列表、函数变量、动态脚本创建(通过 eval)、对象自省(通过 for...inObject 实用工具)以及源代码恢复(JavaScript 函数存储其源文本,可以通过 toString() 检索) )。

¥JavaScript's dynamic capabilities include runtime object construction, variable parameter lists, function variables, dynamic script creation (via eval), object introspection (via for...in and Object utilities), and source-code recovery (JavaScript functions store their source text and can be retrieved through toString()).

本节专门介绍 JavaScript 语言本身,而不是特定于网页或其他主机环境的部分。有关特定于网页的 APIs 的信息,请参阅 网络 APIDOM

¥This section is dedicated to the JavaScript language itself, and not the parts that are specific to Web pages or other host environments. For information about APIs that are specific to Web pages, please see Web APIs and DOM.

JavaScript 的标准是 ECMAScript 语言规范 (ECMA-262) 和 ECMAScript 国际化 API 规范 (ECMA-402)。一旦一个浏览器实现了一项功能,我们就会尝试将其记录下来。这意味着某些 ECMAScript 新功能提案 已经在浏览器、MDN 文章中的文档和示例中实现的情况可能会使用其中一些新功能。大多数情况下,这种情况发生在 阶段 3 和 4 之间,并且通常是在规范正式发布之前。

¥The standards for JavaScript are the ECMAScript Language Specification (ECMA-262) and the ECMAScript Internationalization API specification (ECMA-402). As soon as one browser implements a feature, we try to document it. This means that cases where some proposals for new ECMAScript features have already been implemented in browsers, documentation and examples in MDN articles may use some of those new features. Most of the time, this happens between the stages 3 and 4, and is usually before the spec is officially published.

不要将 JavaScript 与 Java 编程语言 混淆 - JavaScript 不是 "解释型 Java"。"Java" 和 "JavaScript" 都是 Oracle 在美国的商标或注册商标。和其他国家。然而,这两种编程语言具有非常不同的语法、语义和用途。

¥Do not confuse JavaScript with the Java programming languageJavaScript is not "Interpreted Java". Both "Java" and "JavaScript" are trademarks or registered trademarks of Oracle in the U.S. and other countries. However, the two programming languages have very different syntax, semantics, and use.

核心语言功能的 JavaScript 文档(大部分是纯粹的 ECMAScript)包括以下内容:

¥JavaScript documentation of core language features (pure ECMAScript, for the most part) includes the following:

有关 JavaScript 规范和相关技术的更多信息,请参阅 JavaScript 技术概述

¥For more information about JavaScript specifications and related technologies, see JavaScript technologies overview.

教程

¥Tutorials

通过指南和教程了解如何使用 JavaScript 进行编程。

¥Learn how to program in JavaScript with guides and tutorials.

对于完全的初学者

¥For complete beginners

如果你想学习 JavaScript 但之前没有 JavaScript 或编程经验,请前往我们的 学习区 JavaScript 主题。可用的完整模块如下:

¥Head over to our Learning Area JavaScript topic if you want to learn JavaScript but have no previous experience with JavaScript or programming. The complete modules available there are as follows:

JavaScript 第一步

回答一些基本问题,例如 "什么是 JavaScript?"、"它是什么样子的?" 和 "它能做什么?",并讨论关键的 JavaScript 功能,例如变量、字符串、数字和数组。

JavaScript 构建块

继续介绍 JavaScript 的关键基本功能,将我们的注意力转向常见的代码块类型,例如条件语句、循环、函数和事件。

JavaScript 对象介绍

如果你想进一步了解该语言并编写更高效的代码,那么了解 JavaScript 面向对象的本质非常重要,因此我们提供了此模块来帮助你。

异步 JavaScript

讨论异步 JavaScript,为什么它很重要,以及如何使用它来有效处理潜在的阻塞操作,例如从服务器获取资源。

客户端 Web API

探讨什么是 API,以及如何使用你在开发工作中经常遇到的一些最常见的 API。

JavaScript 指南

¥JavaScript guide

JavaScript 指南

更详细的 JavaScript 语言指南,针对那些具有 JavaScript 或其他语言编程经验的人。

中级

¥Intermediate

了解客户端 JavaScript 框架

JavaScript 框架是现代前端 Web 开发的重要组成部分,为开发者提供了经过验证的工具来构建可扩展的交互式 Web 应用。本模块为你提供一些有关客户端框架如何工作以及它们如何适合你的工具集的基本背景知识,然后再继续学习涵盖当今一些最流行的一些框架的一系列教程。

JavaScript 语言概述

JavaScript 基本语法和语义的概述,供来自其他编程语言的人员快速上手。

JavaScript 数据结构

JavaScript 中可用数据结构的概述。

平等比较和相同性

: JavaScript 提供了三种不同的值比较操作:使用 === 的严格相等、使用 == 的松散相等和 Object.is() 方法。

可枚举性和属性所有权

逐一访问一组对象属性的不同方法如何处理属性的可枚举性和所有权。

闭包

闭包是函数和声明该函数的词法环境的组合。

高级

¥Advanced

继承和原型链

对被广泛误解和低估的基于原型的继承的解释。

内存管理

JavaScript 中的内存生命周期和垃圾回收。

事件循环

JavaScript 有一个基于 "事件循环" 的运行时模型。

参考

¥Reference

浏览完整的 JavaScript 参考 文档。

¥Browse the complete JavaScript reference documentation.

标准对象

了解标准内置对象 ArrayBooleanDateErrorFunctionJSONMathNumberObjectRegExpStringMapSetWeakMapWeakSet 等。

表达式和运算符

详细了解 JavaScript 运算符 instanceoftypeofnewthis运算符优先级 等的行为。

语句和声明

了解 do-whilefor-infor-oftry-catchletvarconstif-elseswitch 以及更多 JavaScript 语句和关键字的工作原理。

函数

了解如何使用 JavaScript 函数来开发应用。

JavaScript 类是进行面向对象编程的最合适方法。