The basics of the JavaScript language are indispensable, as it is a universal language that is required in most large and medium companies, along with other languages such as design languages for the web.
What is the JavaScript language?
It is a scripting language, that is, it does not need a compiler, or in other words, the codes of this language are already present in the environment during the runtime. This language appeared in 1995 as it was previously called the Live Script language. The Javascript language is widely used with the design language html and css. Where this language gives the dynamic body to the content of web pages, and it can be used to process information and interact with the user without the need to access the server, and we also note that JavaScript has nothing to do with the Java language.
Uses of the JavaScript language
You may have heard or even learned that the JavaScript language is used only in programming and designing web applications, but in fact, the uses of the JavaScript language are wide, most notably:
presentations.
Many presentations can be made using the JavaScript language, because it provides some libraries such as BespokeJS as well as RevealJS, as the first enables the programmer to create slides for presentations on the Internet, and the second enables you to create many distinctive combinations, whether using HTML or CSS to add beauty mechanism.
Games using javascript language
The JavaScript language is also used in game programming as well, due to the presence of some specialized libraries to facilitate dealing with designs, especially when integrating Javascript with HTML, where there are several well-known games, examples of which are:
Polycraft game that can be used in the browser.
Words With Friends game that works on iPhone phones.
Also a Tower Building game.
2048 is a number puzzle game that can be played online at 2048game.com.
Drawing using the JavaScript language
The JavaScript language alone may not make many other languages. The difference appears clearly, as the html language has a new element, which is the canvas, which adds the ability to draw three-dimensional shapes on the page through the browser, where the JavaScript language is on its side as well.
smart watches
The javascript language may be used in smart watch programming, as there is a Pebble.js library that is used by javascript developers to create applications that run on smart watches.
Mobile applications through the JavaScript language
You may be surprised by the ability of JavaScript to make Android and IOS smartphone applications, as the PhoneGap framework as well as React Native is programmed specifically for that.
Always before learning any programming language, you must ask yourself why do I learn it? Or, in other words, what do I benefit from learning it? In fact, there are many reasons that may push you to learn the basics of the JavaScript language.
JavaScript is one of the most popular languages, according to Stackoverflow.
It is a default language in browsers, and therefore it is important when creating websites, as hardly a site is devoid of it.
Easy to learn and suitable for beginners because it works on browsers easily.
Also, this language is required in the labor market a lot, whether it is in front-end web design or even back-end web programming.
Explain the most important basics of the JavaScript language
A number of basics can be clarified in the JavaScript language, namely variables and their severity, how to bind, functions and comments, how to access and modify elements, events and finally the timer.
Explanation of variables in javascript language
As for variables in the JavaScript language, they are containers for storing data. They are one of the most important basics of the JavaScript language, and it is not required to specify the type of data in the variable. This means that it is closer to the Python language in defining variables, which defines the type of the variable directly, unlike C++ and java.
There are two ways to define a variable of any type:
var method: when using this method to define a variable, these variables can be dealt with within a specific scope, such as functions only, and it is known to programmers as the local or private variable.
let method: When we use let, we can then use the variable and update it from anywhere in the program, which is known as the global variable.
Severity of global variables
Global variables can be in a file written in JavaScript, because they are subject to change by anyone, for example the following program:
and var1 = 0
}()function var2
let var3 = 3
let var4 = 4
{
;var var5 = “hello
In this example, there are three global variables, var1, var2, and var5. You notice that the function itself is a global variable, or for the variables inside it are local. Therefore, even if we put the entire code in one function, we will still have one global variable. So how do we make the number of global variables equal to zero? ?
The following code can be applied to make all variables and functions local:
}() function )
Write all codes and functions here
;() ({
(image on app)
Explanation of linking the javascript file to the html page
In fact, linking a javascript language file is not much different from how to link a css file to an html page, just follow one of the following methods:
Either create a file with the extension js. In the same folder for the html file, then write code in the head tag:
< "script type="text/javascript" scr="file.js>
<script/>
After that you write all the code and functions in the file, this is the best way.
Or open the script tag in the head part as well and then put all the javascript code inside the html file, and this method is not very bad, but we do not like to use it in large projects.
Use the script property in all html tags, then write all JavaScript code inside quotes, separating them using a semicolon.
Functions in javascript language
There are two types of functions that can be used as one of the basics of the JavaScript language, and they are:
Comments
Post a Comment