Sitemap

JavaScript -1

2 min readFeb 11, 2024

JavaScript fundamental

The way of plant the javaScript file in HTML. We can import this into the head tag or end of the body tag.

<script src=“demo.js”></script>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="Demo.js"></script>
</head>
<body>

</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="Demo.js"></script>
</body>
</html>

We use “/ /” for comment a line in JavaScript.

JavaScript variables

Get Janujah Sivarattinam’s stories in your inbox

Join Medium for free to get updates from this writer.

There are three variables in JavaScript. There are var, let, const. Among them let is a local variable var is a global variable and const is a constant variable that can’t we change after the declaration.

let fName = "Medium";
var lName = "Article";
const age = 22;

JavaScript Data type

Press enter or click to view image in full size
/ / Number 
var age = 22;

/ / String
let name = "Medium";

/ / Variable
var x ;

/ / Operations
var add = 4+8;

/ / Boolean
var is_right = true;

/ / Objects
var Array = {
name: "Medium",
id: "As12345S",
age: 22
}

JavaScript Operators

+ : The addition operator is used to add numbers.
- : The subtraction operator is used to subtract numbers.
* : The multiplication operator is used to multiply numbers.
/ : The division operator is used to divide numbers.
% : The modulus operator is used to get the reminder.
++ : The increment operator is used to increase of number by one.
-- : The decrement operator is used to decrease of number by one.

Bitwise operators

&: The bitwise AND operator returns a 1 in every bit position where both operands' corresponding bits are 1.
|: The bitwise OR operator (|) returns a 1 in each bit position where either or both operands' corresponding bits are 1.
~: The bitwise NOT operator reverses the operand's bits. It turns the operand into a 32-bit signed integer, just like other bitwise operators.
^: The bitwise XOR operator () returns a 1 in each bit position where the corresponding bits of both operands are 1s but not both.
<<: The left shift operator shifts the first operand to the left by the provided number of bits. Extra bits that have been relocated to the left are discarded. From the right, zero bits are shifted in
>>: The right shift operator (>>) moves the first operand to the right by the provided number of bits. Extra bits that have been relocated to the right are discarded. The leftmost bit's copies are shifted in from the left. The sign bit (the leftmost bit) does not change since the new leftmost bit has the same value as the old leftmost bit. As a result, the term "sign-propagating" was coined.