JavaScript: Versiyalar orasidagi farq

1 161 bayt qoʻshildi ,  3 yil oldin
Tahrir izohi yoʻq
Teglar: Mobil tahrirlash Mobil dastur orqali tahrirlash
Teglar: Mobil tahrirlash Mobil dastur orqali tahrirlash
JavaScript dasturlash tili sintaktik jihatdan Java dasturlash tiliga, jismli modellashni istisno qilgan holda, o‘xshab ketsada, lekin ma’lumotlarni statik turlari va qat’iy tiplashtirish kabi xususiyatlarga ega bo‘lmaydi. JavaScript, Java dasturlash tilidan farq qilib, sinf tushunchasi bu tilning asosiy sintaktik qurilmasi hisoblanmaydi. Bunday asos sifatida foydalanilayotgan tizim tomonidan qolllab-quvvatlanayotgan, oldindan aniqlangan ma’lumot tiplari: sonli, mantiqiy va satrli; mustaqil ham bo‘lishi, jismning usuli sifatida ham ishlatilishi mumkin bollgan funksiyalar; katta sondagi uz xossalariga va usullariga ega bo‘lgan, hamda oldindan aniqlangan jismlardan iborat jismli model va yana dastur ichida foydalanuvchi tomonidan yangi jismlarni berish qoidalari hisoblanadi.
JavaScript'da dasturlar yaratish uchun hech qanday qo‘shimcha vositalar kerak bo‘lmaydi, faqatgina tegishli versiyadagi JavaScript qo‘llanishi mumkin bo‘lgan brauzer va DHTML hujjatlarni yaratishga imkon beruvchi matn muharriri kerak bo‘ladi. <ref>{{cite web|title="JavaScript" dasturi va uning imkoniyatlari|url=http://tami.uz/matnga_qarang.php?id=438|accessdate=18-fevral, 2018}}</ref>
== Sintaksis ==
===Oddiy mashqlar===
JavaScript'da o‘zgaruvchilarni <tt>var</tt>,<ref>{{cite web | url=https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/var | title=var – JavaScript – MDN | publisher=The [[Mozilla Developer Network]] | accessdate=22 December 2012}}</ref> <tt>let</tt><ref name="moz_let">{{cite web |title=let |url=https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let |website=MDN web docs |publisher=Mozilla |accessdate=27 June 2018 |ref=moz_let}}</ref> yoki <tt>const</tt><ref name="moz_const">{{cite web |title=const |url=https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const |website=MDN web docs |publisher=Mozilla |accessdate=27 June 2018 |ref=moz_const}}</ref> kalitso‘zlari orqali qo‘ying.
<syntaxhighlight lang="javascript">
var x; // declares the variable x and assigns to it the special value "undefined" (not to be confused with an undefined value)
var y = 2; // declares the variable y and assigns to it the value 2
var z = "Hello, World!"; // declares the variable z and assigns to it a string containing "Hello, World!"
</syntaxhighlight>
== Manbalar ==
{{manbalar}}
 
== Havolalar ==
* Douglas Crockford's [https://www.youtube.com/playlist?list=PL62E185BB8577B63D video lectures on JavaScript]