MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/d6d7ff2e2f9c

المقدمة

بينما HTML تحدد بنية صفحات الويب والمحتوى CSS تحدد التنسيق والمظهر، JavaScript تضيف التفاعل إلى صفحة الويب وتنشئ تطبيقات ويب غنية.

ومع ذلك، فإن مصطلح "JavaScript" شامل كما هو مفهوم في سياق متصفح الويب يحتوي على عدة عناصر مختلفة جدا. واحد منهم هو اللغة الأساسية (ECMAScript) وآخر هو جمع Web APIs, بما في ذلك DOM (Document Object Model).

JavaScript, اللغة الأساسية (ECMAScript)

جافاسكريبت الأساسية يتم توحيدها من قبل اللجنة ECMA TC39 كلغة اسمها ECMAScript.

اللغة الأساسية تستخدم أيضاً في بيئات غير المتصفح ، على سبيل المثال في node.js.

ما الذي يندرج ضمن نطاق ECMAScript

من بين أمور أخرى، ECMAScript تعرف:

  • بناء الجملة اللغوية (تحليل القواعد،، الكلمات الدلالية، التحكم في التدفق، التهيئة الحرفية للكائن ...)
  • آليات معالجة الأخطاء (throw, try/catch, والقدرة على إنشاء أنواع الخطأ المعرفة من قبل المستخدم)
  • الأنواع (boolean, number, string, function, object...)
  • الأوبجيكت العام. في المتصفح، هذا الكائن العام هو كائن النافذة، لكن ECMAScript لا يحدد سوى  APIs غير مخصصة للمتصفحات، على سبيل المثال. parseIntparseFloatdecodeURIencodeURI...
  • النموذج الأولي قائم على آلية المورثات
  • المدمج في الكائنات والوظائف  (جسون، الرياضيات، الأراي.أساليب النموذج، طرق الكشف عن الكائنات ...)
  • الوضع الصارم

دعم المتصفح

Browser support

As of October 2016, the current versions of the major Web browsers implement ECMAScript 5.1 and ECMAScript 2015, but older versions (still in use) implement ECMAScript 5 only.

Future

The major 6th Edition of ECMAScript was officially approved and published as a standard on June 17, 2015 by the ECMA General Assembly. Since then ECMAScript Editions are published on a yearly basis.

Internationalization API

The ECMAScript Internationalization API Specification is an addition to the ECMAScript Language Specification, also standardized by Ecma TC39. The internationalization API provides collation (string comparison), number formatting, and date-and-time formatting for JavaScript applications, letting the applications choose the language and tailor the functionality to their needs. The initial standard was approved in December 2012; the status of implementations in browsers is tracked in the documentation of the Intl object. The Internationalization specification is nowadays also ratified on a yearly basis and browsers constantly improve their implementation.

DOM APIs

WebIDL

The WebIDL specification provides the glue between the DOM technologies and ECMAScript.

The Core of the DOM

The Document Object Model (DOM) is a cross-platform, language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Objects in the DOM tree may be addressed and manipulated by using methods on the objects. The W3C standardizes the Core Document Object Model, which defines language-agnostic interfaces that abstract HTML and XML documents as objects, and also defines mechanisms to manipulate this abstraction. Among the things defined by the DOM, we can find:

  • The document structure, a tree model, and the DOM Event architecture in DOM core: Node, Element, DocumentFragment, Document, DOMImplementation, Event, EventTarget, …
  • A less rigorous definition of the DOM Event Architecture, as well as specific events in DOM events.
  • Other things such as DOM Traversal and DOM Range.

From the ECMAScript point of view, objects defined in the DOM specification are called "host objects".

HTML DOM

HTML, the Web's markup language, is specified in terms of the DOM. Layered above the abstract concepts defined in DOM Core, HTML also defines the meaning of elements. The HTML DOM includes such things as the className property on HTML elements, or APIs such as document.body.

The HTML specification also defines restrictions on documents; for example, it requires all children of a ul element, which represents an unordered list, to be li elements, as those represent list items. In general, it also forbids using elements and attributes that aren't defined in a standard.

Looking for the Document object, Window object, and the other DOM elements? Read the DOM documentation.

Other notable APIs

Browser support

As every web developer has experienced, the DOM is a mess. Browser support uniformity varies a lot from feature to feature, mainly because many important DOM features have very unclear, specifications (if any), and different web browsers add incompatible features for overlapping use cases (like the Internet Explorer event model). As of June 2011, the W3C and particularly the WHATWG are defining older features in detail to improve interoperability, and browsers in turn can improve their implementations based on these specifications.

One common, though perhaps not the most reliable, approach to cross-browser compatibility is to use JavaScript libraries, which abstract DOM features and keep their APIs working the same in different browsers. Some of the most widely used frameworks are jQuery, prototype, and YUI.

Document Tags and Contributors

 Contributors to this page: mastinoz
 Last updated by: mastinoz,