Loading, please wait...

A to Z Full Forms and Acronyms

Introduction in JavaScript

Aug 18, 2020 JavaScript, 3273 Views
Introduction to JavaScript

Introduction to JavaScript

The very first step to learning JavaScript (JS) is to learn the syntax and understand the syntax of JavaSript.

var a, b, c; //declare variables
a = 25; //assign
b = 65; //assign
c = a+b; // compute

String

The string can be written with double or single quotes:

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Strings Learn TutorialsLink</h2>

<p>Strings can be written with double or single quotes in JavaScript</p>

<p id="TL"></p>

<script>
document.getElementById("TL").innerHTML = 'Rajib';
</script>

</body>
</html>

Variables

In any programming language, the purpose is to store values in a variable, thus here too in JavaScript values are stored.

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Variables TutorialsLink</h2>

<p>In this example, A is defined as a variable.
Then, A is assigned the value of 100:</p>

<p id="TL"></p>

<script>
var A;
A = 100;
document.getElementById("TL").innerHTML = A;
</script>

</body>
</html>

Operators

Arithmetic Operators are used to performing mathematical operations.

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Operators TutorialsLink</h2>

<p>JavaScript uses arithmetic operators to compute values.</p>

<p id="TL"></p>

<script>
document.getElementById("TL").innerHTML = (45 + 56) * 210;
</script>

</body>
</html>

Comments

Code after double slashes // or between /* and */ is treated as a comment in JavaScript.

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Comments are Not Executed</h1>

<p id="TL"></p>

<script>
var A;
A = 78;
// A = 22; I will not be executed because it is a comment
document.getElementById("TL").innerHTML = A;
</script>

</body>
</html>
A to Z Full Forms and Acronyms

Related Article