Found 10877 Articles for Web Development

What is if statement in JavaScript?

Nishtha Thakur
Updated on 13-Jun-2020 11:37:20

158 Views

The if statement is the fundamental control statement that allows JavaScript to make decisions and execute statements conditionally. SyntaxThe syntax for a basic if statement is as follows −if(expression){    Statement(s)to be executed if expression is true }Here a JavaScript expression is evaluated. If the resulting value is true, the given statement(s) are executed. If the expression is false, then no statement would be not executed. Most of the times, you will use comparison operators while making decisions.ExampleYou can try to run the following to learn how to work with if statement in JavaScript −Live Demo           ... Read More

What is 'new' Operator in JavaScript?

Smita Kapse
Updated on 13-Jun-2020 09:27:27

128 Views

The new keyword in JavaScript is the new operator. It creates an instance of a user-defined object type.SyntaxHere’s the syntax −new constructor[([arguments])]ExampleLet us see an example to learn about the usage of new operator −                          var dept = newObject();          dept.employee = "David";          dept.department = "Programming";          dept.technology = "C++";          document.getElementById("test").innerHTML =          dept.employee + "is working on " + dept.technology + " technology.";          

What is Bitwise XOR Assignment Operator (^=) in JavaScript?

Abhinaya
Updated on 08-Jan-2020 07:51:50

197 Views

It performs XOR operation on the right operand with the left operand and assigns the result to the left operand.ExampleYou can try to run the following code to learn how to work with Bitwise XOR Assignment OperatorLive Demo                    var a = 2;   // Bit presentation 10          var b = 3;   // Bit presentation 11          document.write("(a ^= b) => ");          document.write(a ^= b);          

What is Bitwise OR Assignment Operator (|=) in JavaScript?

Anvi Jain
Updated on 13-Jun-2020 09:25:03

157 Views

It performs OR operation on the right operand with the left operand and assigns the result to the left operand.ExampleYou can try to run the following code to learn how to work with Bitwise OR Assignment Operator −                    var a = 2; // Bit presentation 10          var b = 3; // Bit presentation 11          document.write("(a |= b) => ");          document.write(a |= b);          

What is the "double tilde" (~~) operator in JavaScript?

Nitya Raut
Updated on 13-Jun-2020 09:22:07

2K+ Views

The “double tilde” (~~) operator is a double NOT Bitwise operator. Use it as a substitute for Math.floor(), since it’s faster.ExampleYou can try to run the following code to learn about double tilde operator −                    var a = 2;          var b,c, d;          b = ~~a;          c = Math.floor(a);          d = ~~b=== c;          document.write(b);          document.write(""+c);          document.write(""+d); // They are equal          

What is Addition Operator (+) in JavaScript?

Anvi Jain
Updated on 13-Jun-2020 08:19:52

176 Views

The addition operator is used to add two operands.ExampleYou can try to run the following code to work with Addition Operator −                    var a = 33;          var b = 10;          document.write("a + b = ");          result =a + b;          document.write(result);          

What is Addition Assignment Operator (+=) in JavaScript?

Nitya Raut
Updated on 13-Jun-2020 08:19:32

119 Views

It adds the right operand to the left operand and assigns the result to the left operand.ExampleYou can try to run the following code to learn how to work with Addition Assignment Operator −                    var a = 33;          var b = 10;          document.write("Value of a => (a += b) => ");          result = (a += b);          document.write(result);          document.write(linebreak);          

What is Multiplication Operator (*) in JavaScript?

Abhishek
Updated on 08-Nov-2022 06:37:42

333 Views

In this tutorial, we will learn about the multiplication operator (*) in JavaScript. The multiplication operator is a binary operator which requires at least two operands to operate on. The multiplication operator simply multiplies the left operand with the right operand, or you can say that it simply increases the value of the left operand with the same value till the value of the right operand becomes zero. The example below will explain you everything − 3 * 2 = 6 OR 3 + 3 = 6 5 * 3 = 15 OR 5 + 5 + 5 = 15 ... Read More

What is Modulus Operator (%) in JavaScript?

Abhishek
Updated on 25-Nov-2022 08:07:45

972 Views

In this tutorial, we will learn about the modulus operator in JavaScript. In some languages, the modulus operator is also known as the remainder operator. The remainder operator and the modulus operator both are used to get the remainder of an integer when it is divided by some other integer, but they are different from each other in case of signs of the remainder whether it has to be positive or negative that is returned after the division. In the expression a % b, a is called dividend, while b is known as divisor. In case of the modulo, the ... Read More

How to make a page redirect using jQuery?

Smita Kapse
Updated on 12-Jun-2020 12:20:30

769 Views

To redirect to another webpage in jQuery, use attr(). You can try to run the following code to redirect to another webpage −Example                                $(document).ready(function() {             $(location).attr('href','http://qries.com');          });                  

Advertisements