JavaScript Tutorial

JavaScript is the most popular and widely used client-side scripting language.

Client-side scripting refers to scripts that run in a web browser.

JavaScript is used to add interactivity and other dynamic features to websites.

JavaScript is an object-oriented language and also shares some similarities with the Java programming language in terms of syntax. However, JavaScript has nothing to do with Java.

This tutorial will help you learn the latest JavaScript knowledge from basics to advanced topics.


JavaScript online example

Each chapter of this tutorial contains many practice examples, you can use our online editor to try and test your own js to expand your learning. The purpose of these examples is to give you a better understanding of JavaScript usage.

Basic JavaScript Example


<html>
<title>Javascript Example</title>
<body>

<h1>Getting started with the first javascript example</h1>

<button type="button" onclick="showDate()">click me to show date and time</button>

<p id="output"></p>

<script>
function showDate() {
    document.getElementById("output").innerHTML = new Date();
}
</script>

</body>
</html>

Program Output:-


Why learn JavaScript?

JavaScript is one of 3 languages ​​that web developers must learn:

  1. HTML defines the content of a web page
  2. CSS describes the layout of a web page
  3. JavaScript controls the behavior of web pages

This tutorial is about JavaScript and introduces how JavaScript works with HTML and CSS.


What can JavaScript do?

You can do a lot more with JavaScript:

  • JavaScript can modify text content
  • JavaScript can change the style (CSS) and position of elements
  • JavaScript can change HTML attributes
  • JavaScript can hide and show HTML elements
  • JavaScript can add and remove HTML elements
  • JavaScript can monitor and react to mouse clicks, hovers, etc.
  • JavaScript can create warning popups to display informational or warning messages to the user
  • JavaScript can validate user input before submitting it to the server

Not just these, you can do many other interesting things with JavaScript.


What i should learn before

You don’t need any knowledge of JavaScript before starting this tutorial, but you should have some knowledge of HTML and CSS. It is recommended that you read through the following tutorials before starting to use JavaScript:

If you are a beginner, start with the basics and work your way up by learning a little bit each day.

We recommend that you read this tutorial in the order listed in the menu on the left.