Web programming

What is Javascript?

Ngoc Phuong

Ngoc Phuong

15-02-2020 . 65 view

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.

Ngoc Phuong
Ngoc Phuong

Web Developer

Thank you for visiting my website. My name is Ngoc Phuong, and I have over 10 years of experience in website development. I am confident in stating that I am an expert in creating impressive and effective websites. If you need a website designed, please feel free to contact me via email at [email protected].

0 feedback

Related article