Javascript Switch Statement

A Javascript switch statement is used to execute a block of statements based on the switch expression value. It is like an if else if statement. Syntax: switch(expression){ case value1: //Javascript block of statements break; case value2: //Javascript block of statements break; … default: //Javascript block of statements break; } JavaScript Switch Statement Example: <html> … Read more

Javascript Control Statements

A Javascript control statement is used to control the flow of the program based on the specified condition. Javascript control statements: 1. If Statement 2. If else statement 3. if else if statement JavaScript If Statement: If the statement is used to execute a block of statements if the specified condition is true. Syntax: if(condition){ … Read more

Javascript Operators

Operator is a special symbol used for performing a specific task. e.g. A+B. Here + symbol represents the operator. Types of javascript operators: Javascript Arithmatic Operators Javascript Comparison Operators Javascript Bitwise Operators Javascript Logical Operators Javascript Assignment Operators Javascript Special Operators Example: <!DOCTYPE html> <html> <body> <h2>JavaScript Operators Test</h2> <script> var num1 = 5, num2 … Read more

Javascript Special Operators

Operator Description (?:) Conditional Operator typeof Returns the type of object instanceof Returns true if an object is an instance of an object type   JavaScript Special Operators Example: <html> <head> <script type=”text/javascript”> var a = 10; var b = 20; var c = 10; var d = “String”; var linebreak = “<br />”; document.write … Read more

JavaScript Logical Operators

JavaScript logical operators are used to perform logical operations on the operands. JavaScript Logical Operators List: Operator Description Example && Logical AND (20==40 && 20==30) = false || Logical OR (20==40 || 20==30) = false ! Logical Not !(20==30) = true JavaScript Logical Operators Example: <html> <head> <script type=”text/javascript”> var a = true; var b … Read more

JavaScript Bitwise Operators

JavaScript bitwise operators are used to perform bitwise operations on the operands JavaScript Bitwise Operators List: Operator Description Example & Bitwise AND (10==25 & 20==35) = false | Bitwise OR (20==30 | 20==40) = false ^ Bitwise XOR (20==30 ^ 30==40) = false ~ Bitwise NOT (~20) = -20 << Bitwise Left Shift (10<<2) = … Read more

JavaScript Comparison Operators

JavaScript comparison operators are used to compare the two operands. JavaScript Comparison Operators List: Operator Description Example == Is equal to 10==30 = false === Identical (equal and of the same type) 10==40 = false != Not equal to 20!=20 = true !== Not Identical 20!==20 = false > Greater than 30>10 = true >= … Read more

Javascript Data Types and Variable Scope

JavaScript Data Types: JavaScript Data Types are the types of values that can be represented and manipulated by JavaScript. JavaScript Data Types List: 1. Numbers. 2. Strings. 3. Boolean. 4. Null. 5. Undefined. 6. Object. 7. Array. 8. RegExp. JavaScript variables: The variable is the name of a reserved memory location. In JavaScript, the var … Read more