Javascript Articles - Page 516 of 534

What is Subtraction Operator (-) in JavaScript?

Abhishek
Updated on 06-Jan-2023 12:07:26

2K+ Views

The subtraction operator is also known as the minus operator. It is a binary operator that means it requires at least two operands to operate on. It will not work with a single operand. Generally, the subtraction operator subtracts or minus the value of the second operand from the first operand and returns the result as it is, that means if the result of two numbers subtraction is negative it will return the negative result, else it will return positive result if that’s positive. In this article, we are going to discuss about the subtraction operator in details and its ... Read More

What is Unary Negation Operator (-) in JavaScript?

Abhishek
Updated on 06-Jan-2023 12:13:33

527 Views

The Unary Negation Operator first converts the operand into a number, and after that it negates. It operates on a single operand. It returns the negation of the operand. A boolean operand is converted to 0 or 1, and then negation is done. Similarly, a number with a base other than decimal is first converted to base 10, then the negation is computed. Syntax The following syntax will show you how you can use the unary negation operator to negate the value of a number − -x Here unary operator (-) negates x. Let us understand the application of ... Read More

What is if...else if... statement in JavaScript?

Krantik Chavan
Updated on 13-Jun-2020 11:41:16

453 Views

The if...else if... statement is an advanced form of if…else that allows JavaScript to make a correct decision out of several conditions.SyntaxThe syntax of an if-else-if statement is as follows −if (expression 1){    Statement(s) to be executed if expression 1 is true } else if (expression2){    Statement(s) to be executed if expression 2 is true } else if (expression3){    Statement(s) to be executed if expression 3 is true } else{    Statement(s) to be executed if no expression is true }ExampleYou can try to run the following to learn how to work with if…else if statement in ... Read More

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

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

348 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 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

331 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

286 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 Modulus Operator (%) in JavaScript?

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

1K+ 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 redirect website after certain amount of time without JavaScript?

Anvi Jain
Updated on 08-Jan-2020 07:06:18

6K+ Views

To redirect from an HTML page, use the META Tag. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute. The value of the content is the number of seconds; you want the page to redirect after.Through this, you can automatically redirect your visitors to a new homepage. Set the content attribute to 0, if you want it to load immediately.ExampleThe following is an example of redirecting current page to another page after 2 seconds.Live Demo           Redirection                     This page will redirect in 2 seconds.    

How to use JavaScript to redirect a webpage after 5 seconds?

Abhishek
Updated on 08-Sep-2023 23:14:24

42K+ Views

In this tutorial, we learn to use JavaScript to redirect a webpage after 5 seconds. To redirect a webpage after 5 seconds, use the setInterval() method to set the time interval. Add the webpage in window.location.href object. As we know, whenever we need to call a function or some block of code after a specific delay of time we use the setTimeout() and the setInterval() methods of JavaScript. Lts look at the use of these methods to redirect a web page by 5 seconds. To redirect a page we will use the document.location.href or window.location.href object of JavaScript as shown ... Read More

Advertisements