Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1110139 of JavaScript

  • Revision slug: Web/JavaScript
  • Revision title: JavaScript
  • Revision id: 1110139
  • Created:
  • Creator: enthdoc
  • Is current revision? ไม่ใช่
  • ความคิดเห็น

Revision Content

{{JsSidebar}}

JavaScript (ย่อ JS) เป็นภาษาโปรแกรมชนิดหนึ่ง, ภาษามีขนาดเล็ก, อาศัยตรวจแปลภาษา, มีคุณสมบัติ first-class functions.  คนส่วนใหญ่จะรู้จักว่าเป็นภาษาสคริปต์สำหรับหน้าเวบ แต่ปัจจุบันมีการนำไปใช้ใน สภาพแวดล้อมอื่นๆอีกจำนวนมากที่ไม่ใช่ browser เช่น node.js หรือ Apache CouchDB. JS เป็นภาษาแบบ prototype-based, multi-paradigm, dynamic scripting สนับสนุนสไตล์การเชียนแบบ object-oriented, imperative และ declarative ( เช่น การโปรแกรมแบบ functional) อ่านเพิ่มเติม

ส่วนนี้ของเวปไซท์มีไว้สำหรับภาษา JavaScript โดยเฉพาะ, เนื้อหายังไม่เจาะจงกับการเขียนหน้าเวป หรือ สภาพแวดล้อมอื่นๆ. สำหรับเนื้อหาเกี่ยวกับ APIs สำหรับการเขียนเวปโดยตรงนั้นสามารถดูได้ที่ Web APIs และ DOM

มาตรฐานของ JavaScript คือ ECMAScript. นับตั้งแต่ปี 2012 เป็นต้นมา browser ยุคใหม่ทั้งหมดรองรับการทำงานตามมาตรฐาน ECMAScript 5.1 อย่างสมบูรณ์ ในขณะที่ browser ที่เก่ากว่านั้นจะรองรับอย่างน้อย ECMAScript 3. ในวันที่ 17 มิถุนายน 2015 ECMA International ได้ตีพิมพ์มาตรฐานลำดับที่ 6 ของ ECMAScript ซึ่งมีชื่อเรียกอย่างเป็นทางการว่า ECMAScript 2015 แต่เป็นที่รู้จักโดยทั่วไปว่า ECMAScript 6 หรือ ES6. ตั้งแต่นั้นเป็นต้นมา ECMAScript มาตรฐานก็จะมีการปรับปรุงทุกปี.  สำหรับเอกสาร(ที่ท่านอ่าน) นี้อ้างถึงมาตรฐานฉบับร่างรุ่นล่าสุด ซึ่งปัจจุบันคือ ECMAScript 2017.

อย่าสับสน JavaScript กับ ภาษา Java. ทั้ง  "Java" and "JavaScript" เป็น ตราสินค้าจดทะเบียนของบริษัท Oracle ในสหรัฐอเมริกาและประเทศอื่นๆ). ทั้งสองภาษามีความต่างอย่างมากทั้งด้าน วากยสัมพันธ์ (syntax), ความหมาย (semantics) และการใช้งาน

Tutorials

Learn how to program with JavaScript.

Introductory

JavaScript Guide
If you are new to JavaScript, this guide will walk you through the language.
JavaScript technologies overview
Introduction to the web browser JavaScript landscape.
Introduction to Object Oriented JavaScript
Introduction to the concepts of object oriented programming in JavaScript.

Intermediate

A re-introduction to JavaScript
An overview for those who think they know about JavaScript.
JavaScript data structures
Overview of available data structures in JavaScript.
Equality comparisons and sameness
JavaScript provides three different value-comparison operations: strict equality using === and loose equality using ==.

Advanced

Inheritance and the prototype chain
Explanation of the widely misunderstood and under-estimated prototype-based inheritance.
Strict mode
A restricted variant of JavaScript.
JavaScript typed arrays
JavaScript typed arrays provide a mechanism for accessing raw binary data.
Memory Management
Memory life cycle and garbage collection in JavaScript.

Reference

Browse the complete JS reference documentation.

Standard objects
Get to know standard built-in objects Array, Boolean, Date, Error, Function, JSON, Math, Number, Object, RegExp, String, Map, Set, WeakMap, WeakSet, and others.
Expressions & operators
Learn more about the behavior of JavaScript's operators instanceof, typeof, new, this, and more.
Statements & declarations
Learn how do-while, for-in, for-of, try-catch, let, var, const, if-else, switch, and more JavaScript statements and keywords work.
Functions
Learn how to work with JS functions to develop your applications.

Tools & resources

Helpful tools while writing and debugging your JavaScript code.

Firefox Developer Tools
Scratchpad, Web Console, JavaScript Profiler, Debugger, and more.
Firebug
Edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.
JavaScript Shells
A JavaScript shell allows you to quickly test snippets of JavaScript code.
TogetherJS

Collaboration made easy.

Stack Overflow
Stack Overflow questions tagged with "JavaScript".
JavaScript versions and release notes
Browse JavaScript's feature history and implementation status.

{{CommunityBox("JavaScript", "js-engine.internals", "mozilla.dev.tech.js-engine.internals", "js", "ES discuss|https://esdiscuss.org/|esdiscuss.org|ECMAScript standard discussion mailing list||SpiderMonkey|https://wiki.mozilla.org/JavaScript|Project page|Contribute to the JavaScript Engine||Twitter|https://twitter.com/SpiderMonkeyJS|@SpiderMonkeyJS|SpiderMonkey updates on Twitter")}}

Revision Source

<div>{{JsSidebar}}</div>

<p class="summary"><strong>JavaScript</strong> (ย่อ&nbsp;<strong>JS</strong>) เป็นภาษาโปรแกรมชนิดหนึ่ง, ภาษามีขนาดเล็ก, อาศัยตรวจแปลภาษา, มีคุณสมบัติ&nbsp;<a href="https://en.wikipedia.org/wiki/First-class_functions" title="https://en.wikipedia.org/wiki/First-class_functions">first-class functions.&nbsp;</a> คนส่วนใหญ่จะรู้จักว่าเป็นภาษาสคริปต์สำหรับหน้าเวบ แต่ปัจจุบันมีการนำไปใช้ใน&nbsp;<a href="https://en.wikipedia.org/wiki/JavaScript#Uses_outside_web_pages">สภาพแวดล้อมอื่นๆอีกจำนวนมากที่ไม่ใช่ browser</a> เช่น <a class="external" href="https://nodejs.org/">node.js</a>&nbsp;หรือ&nbsp;<a href="https://couchdb.apache.org/">Apache CouchDB</a>. JS เป็นภาษาแบบ&nbsp;<a class="mw-redirect" href="https://en.wikipedia.org/wiki/Prototype-based_programming" title="Prototype-based">prototype-based</a>, multi-paradigm, dynamic&nbsp;scripting&nbsp;สนับสนุนสไตล์การเชียนแบบ&nbsp;object-oriented, imperative และ declarative ( เช่น การโปรแกรมแบบ functional) <a href="/en-US/docs/Web/JavaScript/About_JavaScript">อ่านเพิ่มเติม</a></p>

<p>ส่วนนี้ของเวปไซท์มีไว้สำหรับภาษา JavaScript โดยเฉพาะ, เนื้อหายังไม่เจาะจงกับการเขียนหน้าเวป&nbsp;หรือ&nbsp;สภาพแวดล้อมอื่นๆ. สำหรับเนื้อหาเกี่ยวกับ <a href="https://en.wikipedia.org/wiki/Application_programming_interface">APIs</a>&nbsp;สำหรับการเขียนเวปโดยตรงนั้นสามารถดูได้ที่&nbsp;<a href="/en-US/docs/Web/API">Web APIs</a> และ <a href="/en-US/docs/Glossary/DOM">DOM</a></p>

<p>มาตรฐานของ&nbsp;JavaScript คือ&nbsp;<a href="/en-US/docs/JavaScript/Language_Resources">ECMAScript</a>. นับตั้งแต่ปี 2012 เป็นต้นมา&nbsp;browser ยุคใหม่ทั้งหมดรองรับการทำงานตามมาตรฐาน&nbsp;ECMAScript 5.1 อย่างสมบูรณ์&nbsp;ในขณะที่ browser ที่เก่ากว่านั้นจะรองรับอย่างน้อย ECMAScript 3. ในวันที่ 17 มิถุนายน 2015&nbsp;<a href="https://www.ecma-international.org/">ECMA International</a>&nbsp;ได้ตีพิมพ์มาตรฐานลำดับที่ 6 ของ&nbsp;ECMAScript&nbsp;ซึ่งมีชื่อเรียกอย่างเป็นทางการว่า&nbsp;ECMAScript 2015 แต่เป็นที่รู้จักโดยทั่วไปว่า&nbsp;ECMAScript 6 หรือ ES6. ตั้งแต่นั้นเป็นต้นมา ECMAScript มาตรฐานก็จะมีการปรับปรุงทุกปี.&nbsp; สำหรับเอกสาร(ที่ท่านอ่าน) นี้อ้างถึงมาตรฐานฉบับร่างรุ่นล่าสุด ซึ่งปัจจุบันคือ <a href="https://tc39.github.io/ecma262/">ECMAScript 2017</a>.</p>

<p>อย่าสับสน JavaScript กับ ภาษา <a href="https://en.wikipedia.org/wiki/Java_(programming_language)">Java</a>. ทั้ง&nbsp; "Java" and "JavaScript" เป็น ตราสินค้าจดทะเบียนของบริษัท Oracle ในสหรัฐอเมริกาและประเทศอื่นๆ). ทั้งสองภาษามีความต่างอย่างมากทั้งด้าน วากยสัมพันธ์ (syntax), ความหมาย (semantics) และการใช้งาน</p>

<div class="column-container">
<div class="column-half">
<h2 id="Tutorials">Tutorials</h2>

<p>Learn how to program with JavaScript.</p>

<h3 id="Introductory">Introductory</h3>

<dl>
 <dt><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide">JavaScript Guide</a></dt>
 <dd>If you are new to JavaScript, this guide will walk you through the language.</dd>
 <dt><a href="/en-US/docs/Web/JavaScript/JavaScript_technologies_overview">JavaScript technologies overview</a></dt>
 <dd>Introduction to the web browser JavaScript landscape.</dd>
 <dt><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript">Introduction to Object Oriented JavaScript</a></dt>
 <dd>Introduction to the concepts of object oriented programming in JavaScript.</dd>
</dl>

<h3 id="Intermediate">Intermediate</h3>

<dl>
 <dt><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript">A re-introduction to JavaScript</a></dt>
 <dd>An overview for those who <em>think</em> they know about JavaScript.</dd>
</dl>

<dl>
 <dt><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures">JavaScript data structures</a></dt>
 <dd>Overview of available data structures in JavaScript.</dd>
 <dt><a href="/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness">Equality comparisons and sameness</a></dt>
 <dd>JavaScript provides three different value-comparison operations: strict equality using <code>===</code> and loose equality using <code>==.</code></dd>
</dl>

<h3 id="Advanced">Advanced</h3>

<dl>
 <dt><a href="/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain">Inheritance and the prototype chain</a></dt>
 <dd>Explanation of the widely misunderstood and under-estimated prototype-based inheritance.</dd>
 <dt><a href="/en-US/docs/Web/JavaScript/Reference/Strict_mode">Strict mode</a></dt>
 <dd>A restricted variant of JavaScript.</dd>
 <dt><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays">JavaScript typed arrays</a></dt>
 <dd>JavaScript typed arrays provide a mechanism for accessing raw binary data.</dd>
 <dt><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management">Memory Management</a></dt>
 <dd>Memory life cycle and garbage collection in JavaScript.</dd>
</dl>
</div>

<div class="column-half">
<h2 id="Reference">Reference</h2>

<p>Browse the complete <a href="/en-US/docs/Web/JavaScript/Reference">JS reference</a> documentation.</p>

<dl>
 <dt><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects">Standard objects</a></dt>
 <dd>Get to know standard built-in objects <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" title="The JavaScript Array global object is a constructor for arrays, which are high-level, list-like objects."><code>Array</code></a></code>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean" title="The Boolean object is an object wrapper for a boolean value."><code>Boolean</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date" title="Creates a JavaScript Date instance that represents a single moment in time. Date objects are based on a time value that is the number of milliseconds since 1 January, 1970 UTC."><code>Date</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error" title="The Error constructor creates an error object. Instances of Error objects are thrown when runtime errors occur. The Error object can also be used as a base objects for user-defined exceptions. See below for standard built-in error types."><code>Error</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" title="The Function constructor creates a new Function object. In JavaScript every function is actually a Function object."><code>Function</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON" title="The JSON object contains methods for parsing JavaScript Object Notation (JSON) and converting values to JSON. It can't be called or constructed, and aside from its two method properties it has no interesting functionality of its own."><code>JSON</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math" title="Math is a built-in object that has properties and methods for mathematical constants and functions. Not a function object."><code>Math</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number" title="The Number JavaScript object is a wrapper object allowing you to work with numerical values. A Number object is created using the Number() constructor."><code>Number</code></a>, <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object"><code>Object</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp" title="The RegExp constructor creates a regular expression object for matching text with a pattern."><code>RegExp</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String" title="The String global object is a constructor for strings, or a sequence of characters."><code>String</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map" title="The Map object is a simple key/value map. Any value (both objects and primitive values) may be used as either a key or a value."><code>Map</code></a>, <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set">Set</a></code>, <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap" title="The WeakMap object is a collection of key/value pairs in which the keys are objects and the values can be arbitrary values."><code>WeakMap</code></a></code>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet" title="The WeakSet object lets you store weakly held objects in a collection."><code>WeakSet</code></a>, and others.</dd>
 <dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators">Expressions &amp; operators</a></dt>
 <dd>Learn more about the behavior of JavaScript's operators <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof">instanceof</a></code>, <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof">typeof</a></code>, <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new">new</a></code>, <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this">this</a></code>, and more.</dd>
 <dt><a href="/en-US/docs/Web/JavaScript/Reference/Statements">Statements &amp; declarations</a></dt>
 <dd>Learn how <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/do...while">do-while</a></code>, <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in">for-in</a></code>, <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of">for-of</a></code>, <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch">try-catch</a></code>, <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let">let</a></code>, <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var">var</a></code>, <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const">const</a></code>, <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else">if-else</a></code>, <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch">switch</a></code>, and more JavaScript statements and keywords work.</dd>
 <dt><a href="/en-US/docs/Web/JavaScript/Reference/Functions">Functions</a></dt>
 <dd>Learn how to work with JS functions to develop your applications.</dd>
</dl>

<h2 id="Tools_resources">Tools &amp; resources</h2>

<p>Helpful tools while writing and debugging your JavaScript code.</p>

<dl>
 <dt><a href="/en-US/docs/Tools">Firefox Developer Tools</a></dt>
 <dd><a href="/en-US/docs/Tools/Scratchpad">Scratchpad</a>, <a href="/en-US/docs/Tools/Web_Console">Web Console</a>, <a href="/en-US/docs/Tools/Profiler">JavaScript Profiler</a>, <a href="/en-US/docs/Tools/Debugger">Debugger</a>, and more.</dd>
 <dt><a class="external" href="https://www.getfirebug.com/">Firebug</a></dt>
 <dd>Edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.</dd>
 <dt><a href="/en-US/docs/Web/JavaScript/Shells">JavaScript Shells</a></dt>
 <dd>A JavaScript shell allows you to quickly test snippets of JavaScript code.</dd>
 <dt><a href="https://togetherjs.com/">TogetherJS</a></dt>
 <dd>
 <p class="hero-header-text large">Collaboration made easy.</p>
 </dd>
 <dt><a href="https://stackoverflow.com/questions/tagged/javascript">Stack Overflow</a></dt>
 <dd>Stack Overflow questions tagged with "JavaScript".</dd>
 <dt><a href="/en-US/docs/Web/JavaScript/New_in_JavaScript">JavaScript versions and release notes</a></dt>
 <dd>Browse JavaScript's feature history and implementation status.</dd>
</dl>
</div>
</div>

<p>{{CommunityBox("JavaScript", "js-engine.internals", "mozilla.dev.tech.js-engine.internals", "js", "ES discuss|https://esdiscuss.org/|esdiscuss.org|ECMAScript standard discussion mailing list||SpiderMonkey|https://wiki.mozilla.org/JavaScript|Project page|Contribute to the JavaScript Engine||Twitter|https://twitter.com/SpiderMonkeyJS|@SpiderMonkeyJS|SpiderMonkey updates on Twitter")}}</p>
Revert to this revision