🕹 JavaScript is the
Programming Language
for the Web.
🕹 JavaScript can update
and change both
HTML and CSS.
🕹 JavaScript can calculate,
manipulate and
validate data.
@javascript_tut
"w3schools .com"
Programming Language
for the Web.
🕹 JavaScript can update
and change both
HTML and CSS.
🕹 JavaScript can calculate,
manipulate and
validate data.
@javascript_tut
"w3schools .com"
JavaScript, often abbreviated as JS,
is a programming language conforms to the ECMAScript specification.
JavaScript is high-level, often just-in-time compiled, and multi-paradigm.
It has curly-bracket syntax, dynamic typing, prototype-based object-orientation, and first-class functions.
@javascript_tut
"Wikipedia"
is a programming language conforms to the ECMAScript specification.
JavaScript is high-level, often just-in-time compiled, and multi-paradigm.
It has curly-bracket syntax, dynamic typing, prototype-based object-orientation, and first-class functions.
@javascript_tut
"Wikipedia"
💻 JavaScript Variables
JavaScript variables are containers for storing data values.
📌 In this example, x, y,
and z, are variables:
📎 Example:
------------------------------
var x = 5;
var y = 6;
var z = x + y;
------------------------------
@javascript_tut
"w3schools .com"
JavaScript variables are containers for storing data values.
📌 In this example, x, y,
and z, are variables:
📎 Example:
------------------------------
var x = 5;
var y = 6;
var z = x + y;
------------------------------
@javascript_tut
"w3schools .com"
📎 Type Syntax
A variable must be declared before it is used. ES5 (JavaScript 5) syntax used the var keyword to achieve the same. The ES5 syntax for declaring a variable is as follows.
📎 Example:
------------------------------
var x = 5;
var y = 6;
var z = x + y;
------------------------------
ES6 (JavaScript 6) introduces the following variable declaration syntax −
📌 Using the let
📌 Using the const
📎 Example:
------------------------------
let x = 5;
const y = 6;
const z = x + y;
------------------------------
@javascript_tut
"Tutorialpoint"
A variable must be declared before it is used. ES5 (JavaScript 5) syntax used the var keyword to achieve the same. The ES5 syntax for declaring a variable is as follows.
📎 Example:
------------------------------
var x = 5;
var y = 6;
var z = x + y;
------------------------------
ES6 (JavaScript 6) introduces the following variable declaration syntax −
📌 Using the let
📌 Using the const
📎 Example:
------------------------------
let x = 5;
const y = 6;
const z = x + y;
------------------------------
@javascript_tut
"Tutorialpoint"
#1. JavaScript Numbers
JavaScript has only one type of number. Numbers can be written with or without decimals.
#2. JavaScript Strings
Strings store text. Strings are written inside quotes. You can use single or double quotes:
#3. JavaScript Objects
You have already learned that JavaScript variables are containers for data values.
Objects are variables too. But objects can contain many values.
#4. JavaScript Arrays
JavaScript arrays are used to store multiple values in a single variable.
#6. JavaScript Functions
A JavaScript function is a block of code designed to perform a particular task.
A JavaScript function is executed when "something" invokes it (calls it).
@javascript_tut
"w3schools .com"
JavaScript has only one type of number. Numbers can be written with or without decimals.
#2. JavaScript Strings
Strings store text. Strings are written inside quotes. You can use single or double quotes:
#3. JavaScript Objects
You have already learned that JavaScript variables are containers for data values.
Objects are variables too. But objects can contain many values.
#4. JavaScript Arrays
JavaScript arrays are used to store multiple values in a single variable.
#6. JavaScript Functions
A JavaScript function is a block of code designed to perform a particular task.
A JavaScript function is executed when "something" invokes it (calls it).
@javascript_tut
"w3schools .com"
📌 JavaScript Output
JavaScript can "display" data in different ways:
#1 Using innerHTML
Writing into an HTML element
#2 Using document.write()
Writing into the HTML output
#3 Using alert()
Writing into an alert box
#4 Using console.log()
Writing into the browser console
@javascript_tut
"w3schools .com"
JavaScript can "display" data in different ways:
#1 Using innerHTML
Writing into an HTML element
#2 Using document.write()
Writing into the HTML output
#3 Using alert()
Writing into an alert box
#4 Using console.log()
Writing into the browser console
@javascript_tut
"w3schools .com"
📕Example: for #innerHTML
-----------------------------------
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
const txt = "Hello, World";
document.getElementById("demo").innerHTML = txt;
</script>
</body>
</html>
@javascript_tut
-----------------------------------
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
const txt = "Hello, World";
document.getElementById("demo").innerHTML = txt;
</script>
</body>
</html>
@javascript_tut
📕Example: for #document.write()
-----------------------------------
<!DOCTYPE html>
<html>
<body>
<script>
var txt = "Hello, World";
document.write(txt);
</script>
</body>
</html>
@javascript_tut
-----------------------------------
<!DOCTYPE html>
<html>
<body>
<script>
var txt = "Hello, World";
document.write(txt);
</script>
</body>
</html>
@javascript_tut