What is Javascript?
Javascript is a very crucial language, it helps to make websites much more dynamic. Let's learn about Javascript through the article below.
I. What is JavaScript?
JavaScript is an interpreted language, its source code is embedded or directly integrated into the HTML file. When the web page finishes loading, the browser interprets and executes these commands.
Before, when people mentioned Javascript, they were only talking about Front-end, but now Javascript can do both Front-end and Back-end thanks to the Node JS platform.
Explanation:
- Front-end: user interaction. Everything you see when navigating online, from images, fonts, colours, to drop-down menus and sliders, combines HTML, CSS, and JavaScript, controlled by your computer's browser.
- Back-end: consists of a server, an application, and a database. Back-end builds and maintains the technology that powers those components, allowing the user interface on the web page to exist.
II. What can JavaScript do?
1. Front-end
On the Front-end, Javascript can do a lot of cool things:
- Make HTML web pages more dynamic.
- React to an event from the user on the website.
- Read or change the content of an HTML element
- Check data
- Detect different types of browsers.
- Create cookie files to store and retrieve information on the visitor's computer.
- ...
Some famous libraries and frameworks on the Javascript Front-end:
- AngularJS: A framework used to build Single Page applications.
- ReactJS: A framework used to build Single Page applications.
- ReactJS Native: A framework used to build mobile applications.
- jQuery: A robust library for effects.
- ...
2. Back-end
On the Back-end, Javascript can also do a lot, thanks to the Node JS platform:
- Make applications for web socket servers such as Online Chat, Game Server…
- Make applications, high-speed file upload programs.
- Make Ad Server applications for ad servers.
- Make Cloud Services applications.
- Write APIs for web, mobile applications.
- Make any application that has real-time speed requirements.
III. Basic way to use Javascript
1. Method 1
Put Javascript commands into the tag of HTML.
Example:
<!DOCTYPE html>
<html>
<body>
<h3>Javascript là gì?</h2>
<script type="text/javascript">
document.write("Hello Word!");
</script>
</body>
</html>
2. Method 2
Create a js file and embed it into HTML.
Example:
//Nội dung file js
function hello() {
alert("Hello Word!")
}
//Nội dung file html
<!DOCTYPE html>
<html>
<head>
<title>Javascript là gì?</title>
<script src="messages.js"></script>
</head>
<body>
<h3>Thực thi lệnh khi người dùng thao tác như nhấn nút button, hover chuột đến phần tử HTML ... gọi chung là sự kiện.</h3>
<button onclick="hello();">Hiển thị câu chào</button>
</body>
</html>
IV. When does Javascript execute commands?
1. Case 1
Execute the command as soon as the webpage is loaded into the user's browser.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Javascript là gì?</title>
<script type="text/javascript">
function hello() {
alert("Hello Word!")
}
</script>
</head>
<body onload="hello();">
<h3>Javacript thực thi lệnh ngay sau khi trang web được tải về trình duyệt của người dùng.</h3>
</body>
</html>
2. Case 2
Execute the command when the user performs actions such as pressing a button, hovering the mouse over an HTML element... collectively called an event.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Javascript là gì?</title>
<script type="text/javascript">
function hello() {
alert("Hello Word!")
}
</script>
</head>
<body>
<h3>Thực thi lệnh khi người dùng thao tác như nhấn nút button, hover chuột đến phần tử HTML ... gọi chung là sự kiện.</h3>
<button onclick="hello();">Hiển thị câu chào</button>
</body>
</html>
V. Some notes when working with Javascript
A Javascript command is a series of commands.
Javascript statements end with a semicolon ;
Distinguish between uppercase and lowercase letters.
Whitespace characters do not affect the execution result of the command.
To comment in Javascript use // for a single line, /* */ for multiple lines.
Submit feedback
Your email address will not be made public. Fields marked are required *
Search
Trend
-
What is Black Myth: Wukong? Detailed Guide on System Requirements and Gameplay
08-21-2024 . 813 view
-
Call of Duty: Black Ops 6 - Intense, Mysterious, and Surprising Warfare
09-02-2024 . 700 view
-
The "End of Life" for Windows 10: A Massive E-Waste Threat and Sustainable Solutions
08-18-2024 . 679 view
-
Casio WS-B1000: The Perfect Blend of Traditional Watch and Smartwatch
08-11-2024 . 597 view
-
Lost All Money by Trusting in "Elon Musk Deepfake": A Cautionary Tale of Deepfake
08-21-2024 . 565 view
0 feedback