fbpx
วิกิพีเดีย

จาวาสคริปต์

จาวาสคริปต์ (JavaScript) เป็นภาษาสคริปต์ ทีมีลักษณะการเขียนแบบโพรโทไทป์ (Prototyped-based Programming) ส่วนมากใช้ในหน้าเว็บเพื่อประมวลผลข้อมูลที่ฝั่งของผู้ใช้งาน แต่ก็ยังมีใช้เพื่อเพิ่มเติมความสามารถในการเขียนสคริปต์โดยฝังอยู่ในโปรแกรมอื่น ๆ

จาวาสคริปต์
กระบวนทัศน์Multi-paradigm: scripting, object-oriented (prototype-based), imperative, functional
เริ่มเมื่อ1995 พฤษภาคม; 26 ปีที่แล้ว (1995-05)
ออกแบบโดยBrendan Eich
ผู้พัฒนาNetscape Communications Corporation, Mozilla Foundation, Ecma International
รุ่นเสถียรECMAScript 6 (17 มิถุนายน 2015; 6 ปีก่อน (2015-06-17))
ระบบชนิดตัวแปรdynamic, duck
ตัวแปลภาษาหลักKJS, Rhino, SpiderMonkey, V8, Carakan, Chakra
ได้รับอิทธิพลจากLua, Scheme, Perl, Self, Java, C, Python, AWK, HyperTalk
ส่งอิทธิพลต่อActionScript, AtScript, CoffeeScript, Dart, JScript .NET, Objective-J, QML, TypeScript, LiveScript
JavaScript ที่วิกิตำรา
JavaScript
นามสกุลไฟล์:.js
ชนิด MIME:
  • application/javascript
  • text/javascript (obsolete)
รูปแบบ:Scripting language

ซัน ไมโครซิสเต็มส์เป็นเจ้าของเครื่องหมายการค้า "JavaScript" โดยมันถูกนำไปใช้ภายใต้สัญญาอนุญาตเพื่อการพัฒนาเทคโนโลยีโดย เน็ตสเคป และมูลนิธิมอซิลลา[ต้องการอ้างอิง]

ประวัติ

เริ่มพัฒนาโดย Brendan Eich พนักงานบริษัทเน็ตสเคป โดยขณะนั้นจาวาสคริปต์ใช้ชื่อว่า โมคา (Mocha) และภายหลังได้เปลี่ยนชื่อมาเป็น ไลฟ์สคริปต์ และเป็น จาวาสคริปต์ในปัจจุบัน รูปแบบการเขียนภาษาที่ใช้ คล้ายคลึงกับภาษาซี รุ่นล่าสุดของจาวาสคริปต์คือ 2.0 ซึ่งตรงกับมาตรฐานของ ECMAScript

ภาษาจาวาสคริปต์ไม่มีความสัมพันธ์กับ ภาษาจาวา (Java) แต่อย่างใด ยกเว้นแต่โครงสร้างภาษาที่มีลักษณะคล้ายคลึงกัน เนื่องมาจากได้รับการพัฒนาต่อมาจากภาษาซีเหมือน ๆ กัน และมีชื่อที่คล้ายคลึงกันเท่านั้น

สำหรับเจสคริปต์ (JScript) หลังจากที่จาวาสคริปต์ประสบความสำเร็จ โดยมีเว็บเบราว์เซอร์จากหลายๆ บริษัทนำมาใช้งาน ทางไมโครซอฟท์จึงได้พัฒนาภาษาโปรแกรมที่ทำงานในลักษณะคล้ายคลึงกับจาวาสคริปต์ขึ้น และตั้งชื่อว่าเจสคริปต์ ซึ่งทำงานได้กับเบราว์เซอร์อินเทอร์เน็ตเอกซ์พลอเรอร์ (Internet Explorer) เท่านั้น เริ่มใช้ครั้งแรกใน อินเทอร์เน็ตเอกซ์พลอเรอร์ 3.0 เมื่อ สิงหาคม พ.ศ. 2539 โดยสร้างตามมาตรฐาน ECMA 262

การใช้งาน

จาวาสคริปต์ เป็นภาษาในรูปแบบของภาษาโปรแกรมแบบโพรโทไทป์ โดยมีโครงสร้างของภาษาและไวยกรณ์อยู่บนพื้นฐานของภาษาซี

ปัจจุบันมีการใช้จาวาสคริปต์ที่ฝังอยู่ในเว็บเบราว์เซอร์ในหลายรูปแบบ เช่น ใช้เพื่อสร้างเนื้อหาที่เปลี่ยนแปลงเสมอภายในเว็บเพจ, ใช้เพื่อตรวจสอบความถูกต้องของข้อมูลที่ผู้ใช้กรอกก่อนนำเข้าระบบ, ใช้เพื่อเข้าถึงข้อมูลที่อยู่ภายใต้โครงสร้างแบบ Document Object Model (DOM) เป็นต้น

นอกจากนี้จาวาสคริปต์ยังถูกฝังอยู่ในแอปพลิเคชันต่าง ๆ นอกเหนือจากเว็บเบราว์เซอร์ได้อีกด้วย เช่น widget ของ ยาฮู! เป็นต้น โดยรวมแล้วจาวาสคริปต์ถูกใช้เพื่อให้นักพัฒนาโปรแกรม สามารถเขียนสคริปต์เพื่อสร้างคุณสมบัติพิเศษต่างๆ เพิ่มเติมจากที่มีอยู่บนแอปพลิเคชันดังเดิม

โปรแกรมใด ๆ ที่สนับสนุนจาวาสคริปต์จะมีตัวขับเคลื่อนจาวาสคริปต์ (JavaScript Engine) ของตัวเอง เพื่อเรียกใช้งานโครงสร้างเชิงวัตถุของโปรแกรมหรือแอปพลิเคชันนั้น ๆ

ตัวอย่างการประกาศใช้งานตัวแปร

ตัวแปร ในจาวาสคริปต์ สามารถประกาศใช้งานได้ด้วยการระบุคำสำคัญ var นำหน้าชื่อตัวแปร:

var x; //ประกาศตัวแปร x, โดยที่ยังไม่มีการใส่ค่า var y = 2; //ประกาศตัวแปร y ให้มีค่าเท่ากับ 2 

ตัวอย่างด้านบน มีการใส่หมายเหตุ ตามหลังการประกาศใช้งานตัวแปร โดยการใส่เครื่องหมายทับ สองตัว (forward slashes)

คอนโซล

คำสั่งที่ใช้ในการตรวจสอบและแสดงผลค่าต่างๆ โดยการเรียกใช้ อ็อบเจกต์ console

console.log("Hello world!"); 

ดูเพิ่ม

อ้างอิง

  • A re-introduction to JavaScript
  1. Flanagan 2011, pp. 1–2.
  2. "Standard ECMA-262". Ecma International. 2015-06-17.
  3. "RFC 4329". Apps.ietf.org. สืบค้นเมื่อ 2013-05-26.
  4. "var - JavaScript - MDN". The Mozilla Developer Network. สืบค้นเมื่อ 22 December 2012.

จาวาสคร, ปต, javascript, เป, นภาษาสคร, ปต, กษณะการเข, ยนแบบโพรโทไทป, prototyped, based, programming, วนมากใช, ในหน, าเว, บเพ, อประมวลผลข, อม, ลท, งของผ, ใช, งาน, แต, งม, ใช, เพ, อเพ, มเต, มความสามารถในการเข, ยนสคร, ปต, โดยฝ, งอย, ในโปรแกรมอ, ๆกระบวนท, ศน, mult. cawaskhript JavaScript epnphasaskhript thimilksnakarekhiynaebbophrothithp Prototyped based Programming swnmakichinhnaewbephuxpramwlphlkhxmulthifngkhxngphuichngan aetkyngmiichephuxephimetimkhwamsamarthinkarekhiynskhriptodyfngxyuinopraekrmxun cawaskhriptkrabwnthsnMulti paradigm scripting object oriented prototype based imperative functional 1 erimemux1995 phvsphakhm 26 pithiaelw 1995 05 xxkaebbodyBrendan EichphuphthnaNetscape Communications Corporation Mozilla Foundation Ecma InternationalrunesthiyrECMAScript 6 2 17 mithunayn 2015 6 pikxn 2015 06 17 rabbchnidtwaeprdynamic ducktwaeplphasahlkKJS Rhino SpiderMonkey V8 Carakan ChakraidrbxiththiphlcakLua Scheme Perl Self Java C Python AWK HyperTalksngxiththiphltxActionScript AtScript CoffeeScript Dart JScript NET Objective J QML TypeScript LiveScriptJavaScript thiwikitaraJavaScriptnamskulifl jschnid MIME style body skin minerva mw parser output hlist dl body skin minerva mw parser output hlist ol body skin minerva mw parser output hlist ul margin 0 padding 0 body skin minerva mw parser output hlist dd body skin minerva mw parser output hlist dt body skin minerva mw parser output hlist li margin 0 display inline body skin minerva mw parser output hlist inline body skin minerva mw parser output hlist inline dl body skin minerva mw parser output hlist inline ol body skin minerva mw parser output hlist inline ul body skin minerva mw parser output hlist dl dl body skin minerva mw parser output hlist dl ol body skin minerva mw parser output hlist dl ul body skin minerva mw parser output hlist ol dl body skin minerva mw parser output hlist ol ol body skin minerva mw parser output hlist ol ul body skin minerva mw parser output hlist ul dl body skin minerva mw parser output hlist ul ol body skin minerva mw parser output hlist ul ul display inline body skin minerva mw parser output hlist mw empty li body skin minerva mw parser output hlist mw empty elt display none body skin minerva mw parser output hlist dt after content body skin minerva mw parser output hlist dd after body skin minerva mw parser output hlist li after content font weight bold body skin minerva mw parser output hlist dd last child after body skin minerva mw parser output hlist dt last child after body skin minerva mw parser output hlist li last child after content none body skin minerva mw parser output hlist dd dd first child before body skin minerva mw parser output hlist dd dt first child before body skin minerva mw parser output hlist dd li first child before body skin minerva mw parser output hlist dt dd first child before body skin minerva mw parser output hlist dt dt first child before body skin minerva mw parser output hlist dt li first child before body skin minerva mw parser output hlist li dd first child before body skin minerva mw parser output hlist li dt first child before body skin minerva mw parser output hlist li li first child before content font weight normal body skin minerva mw parser output hlist dd dd last child after body skin minerva mw parser output hlist dd dt last child after body skin minerva mw parser output hlist dd li last child after body skin minerva mw parser output hlist dt dd last child after body skin minerva mw parser output hlist dt dt last child after body skin minerva mw parser output hlist dt li last child after body skin minerva mw parser output hlist li dd last child after body skin minerva mw parser output hlist li dt last child after body skin minerva mw parser output hlist li li last child after content font weight normal body skin minerva mw parser output hlist ol counter reset listitem body skin minerva mw parser output hlist ol li counter increment listitem body skin minerva mw parser output hlist ol li before content counter listitem a0 body skin minerva mw parser output hlist dd ol li first child before body skin minerva mw parser output hlist dt ol li first child before body skin minerva mw parser output hlist li ol li first child before content counter listitem a0 style div class hlist hlist separated ul li tt application javascript tt li li tt text javascript tt obsolete li ul div rupaebb Scripting languagesn imokhrsisetmsepnecakhxngekhruxnghmaykarkha JavaScript odymnthuknaipichphayitsyyaxnuyatephuxkarphthnaethkhonolyiody entsekhp aelamulnithimxsilla txngkarxangxing enuxha 1 prawti 2 karichngan 2 1 twxyangkarprakasichngantwaepr 2 2 khxnosl 3 duephim 4 xangxingprawti aekikherimphthnaody Brendan Eich phnknganbristhentsekhp odykhnanncawaskhriptichchuxwa omkha Mocha aelaphayhlngidepliynchuxmaepn ilfskhript aelaepn cawaskhriptinpccubn rupaebbkarekhiynphasathiich khlaykhlungkbphasasi runlasudkhxngcawaskhriptkhux 2 0 sungtrngkbmatrthankhxng ECMAScriptphasacawaskhriptimmikhwamsmphnthkb phasacawa Java aetxyangid ykewnaetokhrngsrangphasathimilksnakhlaykhlungkn enuxngmacakidrbkarphthnatxmacakphasasiehmuxn kn aelamichuxthikhlaykhlungknethannsahrbecskhript JScript hlngcakthicawaskhriptprasbkhwamsaerc odymiewbebrawesxrcakhlay bristhnamaichngan thangimokhrsxfthcungidphthnaphasaopraekrmthithanganinlksnakhlaykhlungkbcawaskhriptkhun aelatngchuxwaecskhript sungthanganidkbebrawesxrxinethxrentexksphlxerxr Internet Explorer ethann erimichkhrngaerkin xinethxrentexksphlxerxr 3 0 emux singhakhm ph s 2539 odysrangtammatrthan ECMA 262karichngan aekikhcawaskhript epnphasainrupaebbkhxngphasaopraekrmaebbophrothithp odymiokhrngsrangkhxngphasaaelaiwykrnxyubnphunthankhxngphasasipccubnmikarichcawaskhriptthifngxyuinewbebrawesxrinhlayrupaebb echn ichephuxsrangenuxhathiepliynaeplngesmxphayinewbephc ichephuxtrwcsxbkhwamthuktxngkhxngkhxmulthiphuichkrxkkxnnaekharabb ichephuxekhathungkhxmulthixyuphayitokhrngsrangaebb Document Object Model DOM epntnnxkcaknicawaskhriptyngthukfngxyuinaexpphliekhchntang nxkehnuxcakewbebrawesxridxikdwy echn widget khxng yahu epntn odyrwmaelwcawaskhriptthukichephuxihnkphthnaopraekrm samarthekhiynskhriptephuxsrangkhunsmbtiphiesstang ephimetimcakthimixyubnaexpphliekhchndngedimopraekrmid thisnbsnuncawaskhriptcamitwkhbekhluxncawaskhript JavaScript Engine khxngtwexng ephuxeriykichnganokhrngsrangechingwtthukhxngopraekrmhruxaexpphliekhchnnn twxyangkarprakasichngantwaepr aekikh twaepr incawaskhript samarthprakasichnganiddwykarrabukhasakhy var nahnachuxtwaepr 4 var x prakastwaepr x odythiyngimmikariskha var y 2 prakastwaepr y ihmikhaethakb 2 twxyangdanbn mikarishmayehtu tamhlngkarprakasichngantwaepr odykarisekhruxnghmaythb sxngtw forward slashes khxnosl aekikh khasngthiichinkartrwcsxbaelaaesdngphlkhatang odykareriykich xxbeckt console console log Hello world duephim aekikheckhwirixangxing aekikhA re introduction to JavaScript Flanagan 2011 pp 1 2 Standard ECMA 262 Ecma International 2015 06 17 RFC 4329 Apps ietf org subkhnemux 2013 05 26 var JavaScript MDN The Mozilla Developer Network subkhnemux 22 December 2012 ekhathungcak https th wikipedia org w index php title cawaskhript amp oldid 9621089, wikipedia, วิกิ หนังสือ, หนังสือ, ห้องสมุด,

บทความ

, อ่าน, ดาวน์โหลด, ฟรี, ดาวน์โหลดฟรี, mp3, วิดีโอ, mp4, 3gp, jpg, jpeg, gif, png, รูปภาพ, เพลง, เพลง, หนัง, หนังสือ, เกม, เกม