Javascript String Object

A JavaScript String object represents a sequence of characters. How to create a Javascript string object: 1. By using string literals. 2. By using String() constructor. By using string literals: When we create a string literal browser automatically converts it to a String object. Syntax: var string1 = “value”; Example: <!DOCTYPE html> <html> <body> <script> … Read more

Javascript Boolean Object

A JavaScript Boolean object can represent two values “true” or “false”. How to create a Javascript boolean object: 1. By using boolean literals. 2. By using Boolean() constructor. Syntax: Var b1 = true; var b2 = new Boolean(value); Example: <!DOCTYPE html> <html> <body> <script> var boolean1=new Boolean(true); var boolean2=new Boolean(false); var boolean3=true; document.write(“Boolean1: “+boolean1+ “</br>”); … Read more

Javascript Number Object

The JavaScript Number object represents numerical data which can be integers or floating-point numbers. How to create a Javascript number object: 1. By using number literals. 2. By using Number() constructor. By using number literals: When we create a number literal browser automatically converts it to a Number object. Syntax: var num1 = value; Example: … Read more

Javascript Function

A javascript function is a group of statements that is used for performing a specific task. We can invoke it from anywhere in our program. It provides the facility of code re-usability. Syntax: function functionname(parameterList) { //Block of statements } JavaScript Function Object: For the global execution of a piece of code, a new Function … Read more

Javascript For Loop Continue

The continue statement is a control statement that is used to skip the following statement in the body of the loop and continue with the next iteration of the loop. Syntax: for( initialization; condition; statement){ //Block of statements if(condition){ continue; } } Where: initialization statement: is used to initialize the loop variable. boolean expression: is … Read more

Javascript For Loop Break

The break statement is a control statement that is used to jump out of the loop. Syntax: for( initialization; condition; statement){ //Block of statements if(condition){ break; } } Where: initialization statement: is used to initialize the loop variable. boolean expression: is used for condition check whether returns true or false. statement: is used for either … Read more

Javascript Do While Loop

The do while loop repeatedly executes a block of statements until a particular condition is true. It first executes a block of statements and then checks the condition. Syntax: do { //Block of statements }while(condition); JavaScript do while loop example: <html> <head> <script> var num=1; do{ document.write(num + “<br/>”) ; num++; } while (num<=10) </script> … Read more

Javascript While Loop

The while loop repeatedly executes a block of statements until a particular condition is true. It first checks the condition and executes a block of statements if the condition is true. Syntax: while(condition){ //Block of statements } JavaScript while loop example: <html> <head> <script> var num=1; while (num<=10) { document.write(num + “<br/>”); num++; } </script> … Read more

Javascript For in Loop

The for in loop is used to iterate the properties of an object. Syntax: for(property in object){ //Block of statements } JavaScript for in loop example: <html> <head> <script> var person = {Fname:”Mahesh”, Lname:”Kumawat”, Age:29}; var perproperty; for (perproperty in person) { document.write(perproperty + “: ” + person[perproperty ] + “<br/>”) } </script> </head> <body> … Read more

Javascript For Loop

The for loop repeatedly executes a block of statements until a particular condition is true. Syntax: for(initialization; condition; statement){ //Block of statements } Where: initialization statement: is used to initialize the loop variable. boolean expression: is used for condition check whether returns true or false. statement: is used for either increment or decrement of the … Read more