JavaScript

出自維基百科,自由嘅百科全書
JavaScript
非官方JavaScript標誌
編程範式手稿語言物件導向基於原型)、指令式函數式
設計者布蘭登艾卡中文布蘭登·艾克
編程員網景Mozilla基金會中文Mozilla基金會
第一次出現1995年, 29年之前 (1995)
穩定版本
ECMAScript 2016[1] / 2016年6月17號, 7年之前 (2016-06-17)
類型系統類型系統duck
網站www.ecma-international.org/publications-and-standards/standards/ecma-262/
Major implementations
V8JavaScriptCoreSpiderMonkeyChakra
啟發語言
CJavaPerlPythonSchemeSelf中文Self
影響語言
ActionScriptCoffeeScriptDartJScript .NETObjective-JQMLTIScriptTypeScript

JavaScript係一種高級程式語言直譯語言[2]。佢已經由ECMA通過ECMAScript標準化[2]。世界上大多數主流瀏覽器ChromeFirefoxIE/EdgeSafari等等)都支援JavaScript[3]

演變[編輯]

網頁格式喺1990年代首次出現,嗰陣時嘅瀏覽器(Browser)只係可以辯認HTML語言,爾啲語言係用來話畀我哋知瀏覽器顯示咩資料,係靜態性嘅操作,Netscape Navigator 1.0就係爾類嘅瀏覽器。

編程[編輯]

console.log("a");    //啱
console.log("b");    //啱
console.logg("c");   //錯,來到爾度停低
console.log("d");    //啱
console.log("e");    //啱

/*解決辦法*/
try{console.log("a");}catch(e){}    //啱
try{console.log("b");}catch(e){}    //啱
try{console.logg("c");}catch(e){}   //錯,但係到爾度毋會停低,而係跳過
try{console.log("d");}catch(e){}    //啱
try{console.log("e");}catch(e){}    //啱

例子[編輯]

Hello World:

alert("Hello World!");

資料類型[編輯]

  • 布林值(Boolean)
  • 數字(Number)
  • 大整數(BigInt)
  • 字串(String)
  • 符號(Symbol)
  • 陣列(Array)
  • 集合(Set)
  • 物件(Object)
  • 映射(Map)
  • 函式(Function)
  • 未定義(undefined)
  • 空(null)

語法[編輯]

條件語句有 if , switch。

if(條件)
{
	當條件係true嗰時執行
}
else
{
	當條件係false嗰時執行
}
switch(條件)
{
	case 0 :
	當條件係數字0嗰時執行
	break ;
	
	case "0" :
	當條件係字串0嗰時執行
	break ;
	
	default :
	其他情況執行
}

循環語句有 for , while。

跳轉語句有 break , continue , return , yield。

運算子[編輯]

+ 加法
- 減法
* 乘法
/ 除法
% 取餘(mod)
** 

參攷[編輯]

  1. "Standard ECMA-262". Ecma International. 2015-06-17.
  2. 2.0 2.1 David, Flanagan (2011). JavaScript: The Definitive Guide (第6版). O'Reilly & Associates. ISBN 978-0-596-80552-4.
  3. "ECMAScript 6 compatibility table". kangax. 原著喺2016-07-27歸檔. 喺2018-03-03搵到.

睇埋[編輯]

  • 同JavaScript完全係兩回事嘅Java