Articles on Trending Technologies

Technical articles with clear explanations and examples

How to redirect website after certain amount of time without JavaScript?

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 6K+ Views

To redirect from an HTML page without JavaScript, use the META tag with the http-equiv="refresh" attribute. This provides an HTTP header that tells the browser to automatically redirect after a specified number of seconds. Through this method, you can automatically redirect your visitors to a new homepage or any other page. Set the content attribute to 0 if you want the redirect to happen immediately. Syntax Parameters The content attribute contains two parts separated by a semicolon: seconds - Number of seconds to wait before redirecting url - The destination ...

Read More

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

Abhishek
Abhishek
Updated on 15-Mar-2026 43K+ Views

In this tutorial, we learn to use JavaScript to redirect a webpage after 5 seconds. To redirect a webpage after a delay, we use the setTimeout() method combined with window.location.href to set the destination URL. JavaScript provides two timing methods for delayed execution: setTimeout() for single execution and setInterval() for repeated execution. For page redirection, setTimeout() is the preferred method. To redirect a page we use the window.location.href property to change the current page URL: window.location.href = "https://example.com"; Using setTimeout() Method (Recommended) The setTimeout() method executes a function once after a specified delay. ...

Read More

What is unsigned Right Shift Operator (>>>) in JavaScript?

Nancy Den
Nancy Den
Updated on 15-Mar-2026 718 Views

The unsigned right shift operator (>>>) shifts the binary representation of a number to the right by a specified number of positions, filling the leftmost bits with zeros regardless of the original sign bit. Syntax result = number >>> positions How It Works Unlike the signed right shift (>>) which preserves the sign bit, the unsigned right shift always fills with zeros from the left. This treats the number as an unsigned 32-bit integer. Example with Positive Number var a = 14; var b = 2; // Shift ...

Read More

What is the difference between == and === in JavaScript?

Daniol Thomas
Daniol Thomas
Updated on 15-Mar-2026 1K+ Views

In JavaScript, == (double equals) performs loose equality comparison with type coercion, while === (triple equals) performs strict equality comparison without type conversion. Double Equals (==) - Loose Equality The == operator converts operands to the same type before comparing them. This can lead to unexpected results: console.log(4 == 4); // true console.log('4' == 4); // true - string converted to number console.log(4 == '4'); // true - number converted to string console.log(0 == false); // ...

Read More

How to load a JavaScript function using the variable name?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 2K+ Views

In JavaScript, there are several ways to load and execute functions using variable names. This technique is useful when you need to dynamically call functions or store function references in variables. Functions are blocks of reusable code that can be stored in variables and called later. JavaScript supports both named functions and anonymous functions, giving you flexibility in how you organize and execute your code. Anonymous Functions Anonymous functions are functions without a name. They must be assigned to a variable to be callable. This is the primary way to load a JavaScript function using a variable ...

Read More

How to use JavaScript to hide a DIV when the user clicks outside of it?

Rishi Raj
Rishi Raj
Updated on 15-Mar-2026 1K+ Views

To hide a DIV when the user clicks outside of it, you can listen for click events on the document and check if the clicked element is the target DIV or one of its children. This technique is commonly used for closing modals, dropdowns, and tooltips. Basic Implementation The simplest approach is to attach a click listener to the document and hide the DIV when the click target is not the DIV itself: #hideMe { ...

Read More

What is the difference between decodeURIComponent and decodeURI?

Vikyath Ram
Vikyath Ram
Updated on 15-Mar-2026 647 Views

JavaScript provides two methods for decoding URL-encoded strings: decodeURIComponent() and decodeURI(). Understanding their differences is crucial for proper URL handling in web applications. decodeURIComponent The decodeURIComponent() method decodes all encoded characters in a URI component, including reserved characters like =, &, and ?. Syntax decodeURIComponent(encodedURIComponent) Example Test decodeURIComponent function displayComponent() { ...

Read More

What is the difference between single and double quotes in JavaScript?

Kumar Varma
Kumar Varma
Updated on 15-Mar-2026 373 Views

In JavaScript, you can use either single quotes or double quotes to define strings. Both are functionally identical, but it's important to maintain consistency throughout your code. Syntax let singleQuoted = 'Hello World'; let doubleQuoted = "Hello World"; Basic Examples let message1 = "Hello, JavaScript!"; let message2 = 'Hello, JavaScript!'; console.log(message1); console.log(message2); console.log(message1 === message2); // Both are identical Hello, JavaScript! Hello, JavaScript! true Escaping Quotes When your string contains quotes, you need to escape them or use the opposite quote type: // Escaping ...

Read More

How to write a JavaScript function to get the difference between two numbers?

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 9K+ Views

Use Math.abs() inside a JavaScript function to get the difference between two numbers in JavaScript. The Math.abs() method returns the absolute value, ensuring you always get a positive difference regardless of which number is larger. Syntax function getDifference(num1, num2) { return Math.abs(num1 - num2); } Example: Using Math.abs() for Difference You can try to run the following code to get the difference of numbers: var num1, num2; ...

Read More

What does the operator || do in a var statement in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 357 Views

In JavaScript, the logical OR operator (||) is commonly used in variable declarations to provide fallback or default values. When used with var, it returns the first "truthy" value or the last value if all are falsy. The logical OR operator evaluates operands from left to right and returns the first truthy value it encounters. If no truthy value is found, it returns the last operand. In JavaScript, falsy values include false, 0, "", null, undefined, and NaN. Syntax var result = expr1 || expr2; If expr1 is truthy, result will be expr1. Otherwise, ...

Read More
Showing 19071–19080 of 61,299 articles
Advertisements