This article is currently in the process of being translated into Uzbek (~19% done).
JavaScript and the webbrowser
Ko‘pchilik odamlar uchun JavaScript va veb-brauzer juda yaqin aloqador. Bu mantiqqa to‘g‘ri keladi, chunki JavaScript dastlab Netscape Navigator veb-brauzerini yaratgan jamoa tomonidan ishlab chiqilgan va faqat Internetda qo‘llanilgan edi. Shu sababli JavaScriptni ko‘pincha "xavfsiz til" deb atashadi, chunki u o‘zining eng keng tarqalgan amaliyotida hech qachon asosiy fayl tizimiga yoki shunga o‘xshash narsalarga kirish imkonini bermaydi. Buning o‘rniga, u ko‘proq tizimga bog‘liq bo‘lmagan "yaxshi" ishlarni bajarishingiz mumkin bo‘lgan qumdonni eslatadi.
Biroq shuni ta’kidlash joizki, JavaScriptni veb-brauzerdan tashqarida ham bemalol qo‘llash mumkin. JavaScript ishlashi uchun JavaScript dvigateli yoki tarjimonidan foydalanadi. Bu dvigatel brauzer ichida ishlashi mumkin va u insoniyatga ma’lum bo‘lgan deyarli barcha zamonaviy veb-brauzerlarda ishlaydi. Ammo bu dvigatelning brauzerdan tashqarida ishlashiga hech narsa to‘sqinlik qilmaydi. Aslida, bu ko‘p marotaba amalga oshirilgan.
Node.js
The most notable example of this is the Node.js project. Created in 2009, it basically pulled the JavaScript engine out of the webbrowser and added modules to make JavaScript an all-purpose programming language instead of a webbrowser scripting language. This sparked a new and much higher level of interest in JavaScript, because now you could use your JavaScript skills for both the web (clientside) and for doing serverside scripts. And since Node.js is cross-platform, this suddenly allowed you to run your code across Windows, Linux, Unix, and macOS, without needing a browser.
Host muhiti
All of this leads us to the discussion of the host environment. The host environment is where your JavaScript is executed, and usually it includes functionality not directly found in the JavaScript language. The most obvious example of this is of course the webbrowser, which adds a LOT of functionality, allowing your JavaScript code to communicate with the browser and manipulate the contents of the underlying website.
Another hosting environment could be Node.js, adding serverside related functionality, but since JavaScript was originally designed to be able to run anywhere, this could also be your coffee machine. It could easily include a JavaScript engine and add functionality related to making coffee and taking instructions from push buttons instead of a website.
Brauzer bilanmi yoki brauzersizmi?
So, as you can see, JavaScript can definitely run outside the webbrowser. That's true now, and I can only imagine that the increasing popularity of JavaScript will make this even more true in the future. Therefore, it's important for me to stress that in this tutorial, we will first and foremost learn the JavaScript language.
So, in the first part of this tutorial, we will focus on the actual language and not talk too much about how it can interact with a browser. With that in mind, it would be silly to completely ignore how JavaScript interacts with the webbrowser since this is still such a common use case. Therefore, the latter part of this tutorial will be dedicated to exactly this subject, where we will dig deeper into the ties between JavaScript and the webbrowser.
A little heads-up to the purists out there: You might notice that even though we keep the browser out of the equation during the first part of the tutorial, I will be using a couple of functions which could be considered browser related. An example of this is the alert() function, which will show a simple message box in the browser. I use it because it's simple and easy to understand in the examples we use in this tutorial, and because it produces a result which can be seen when reading the tutorial in a webbrowser and running the examples directly from the website.
Xulosa
JavaScript is often run inside a webbrowser, but not always. In this tutorial we will focus on the core JavaScript language first, allowing you to learn the language, and then later on, we will look into how JavaScript can interact with a webbrowser. However, we will be showing you examples where we interact a bit with the browser, simply because it's easy to understand and can be tested while you read the articles.