Articles on Trending Technologies

Technical articles with clear explanations and examples

Can someone explain to me what the plus sign is before the variables in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 3K+ Views

The plus (+) sign before a variable in JavaScript is the unary plus operator. It converts the value to a number, making it useful for type conversion from strings, booleans, or other data types to numeric values. Syntax +value How It Works The unary plus operator attempts to convert its operand to a number. It works similarly to Number() constructor but with shorter syntax. Example: String to Number Conversion var firstValue = "1000"; console.log("The data type of firstValue = " + typeof firstValue); var secondValue = 1000; console.log("The data type ...

Read More

Fetching JavaScript keys by their values - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 277 Views

In JavaScript, you can find an object key by its value using several approaches. This is useful when you need to perform reverse lookups in objects where both keys and values are unique. Consider this object where we want to find keys by their corresponding values: const products = { "Pineapple": 38, "Apple": 110, "Pear": 109 }; console.log(products); { Pineapple: 38, Apple: 110, Pear: 109 } Using Object.keys() with find() The most straightforward approach uses Object.keys() with find() to locate the ...

Read More

How to create a strikethrough text using JavaScript?

Akshaya Akki
Akshaya Akki
Updated on 15-Mar-2026 5K+ Views

To create a strikethrough text with JavaScript, you can use several methods. The legacy strike() method wraps text in deprecated tags, while modern approaches use CSS styling for better compatibility. Using the Legacy strike() Method The strike() method creates strikethrough text by wrapping it in tags. However, this method is deprecated and not recommended for new projects. JavaScript String strike() Method var str = "Demo Text"; ...

Read More

How to load the previous URL in the history list in JavaScript?

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

In this tutorial, we will learn to load the previous page in the history list in JavaScript. The Window object in JavaScript accesses the window in the browser. This object contains many properties and methods required to do the tasks. The Window object also retrieves the information from the browser window. There is a history stack in every browser that saves the pages visited by the user. To access this history stack, we can use the history object that is the property of the Window object. By accessing the history from the browser, we can go to the ...

Read More

How to set the shadow effect of a text with JavaScript?

Sravani S
Sravani S
Updated on 15-Mar-2026 1K+ Views

The textShadow property in JavaScript allows you to add shadow effects to text elements. This property accepts values for horizontal offset, vertical offset, blur radius, and color. Syntax element.style.textShadow = "h-shadow v-shadow blur-radius color"; Parameters h-shadow: Horizontal offset of the shadow (required) v-shadow: Vertical offset of the shadow (required) blur-radius: Blur distance of the shadow (optional) color: Color of the shadow (optional) Example: Basic Text Shadow Add Text Shadow Remove Shadow ...

Read More

How to fix Array indexOf() in JavaScript for Internet Explorer browsers?

Ramu Prasad
Ramu Prasad
Updated on 15-Mar-2026 517 Views

Internet Explorer versions 8 and below don't support the Array.indexOf() method. This article shows how to fix this compatibility issue using polyfills and jQuery alternatives. The Problem In modern browsers, indexOf() returns the first index of an element in an array, or -1 if not found. However, IE8 and earlier throw an error when you try to use this method. Method 1: Using Array Polyfill Add this polyfill to support indexOf() in older IE browsers: Method 2: Using jQuery.inArray() jQuery provides a cross-browser alternative with jQuery.inArray(): // Syntax: ...

Read More

Cross origin HTML does not load in Google Chrome

Samual Sam
Samual Sam
Updated on 15-Mar-2026 259 Views

When loading HTML content from a different origin in Google Chrome, you may encounter CORS (Cross-Origin Resource Sharing) errors. This happens because browsers enforce the same-origin policy for security reasons. Common Cross-Origin Issues Cross-origin problems typically occur when: Loading resources from different domains Using different protocols (HTTP vs HTTPS) Different ports on the same domain Missing proper CORS headers Solution 1: Setting crossorigin for Video Elements For video elements that fail to load cross-origin content, set the crossorigin attribute to "anonymous": Cross-Origin Video ...

Read More

How to set the whitespace between text in CSS?

vanithasree
vanithasree
Updated on 15-Mar-2026 289 Views

The CSS white-space property controls how whitespace characters (spaces, tabs, line breaks) are handled within text elements. This property is essential for controlling text formatting and layout. Syntax white-space: value; White-space Property Values Value Spaces/Tabs Line Breaks Text Wrapping normal Collapsed Ignored Yes pre Preserved Preserved No nowrap Collapsed Ignored No pre-wrap Preserved Preserved Yes pre-line Collapsed Preserved Yes Example: Using white-space: pre The pre value preserves all whitespace and line breaks, similar to the HTML tag: ...

Read More

How to Find the action Attribute and method of a Form in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 15-Mar-2026 3K+ Views

In HTML forms, the action and method attributes control where form data is sent and how it's transmitted. JavaScript provides properties to access and modify these attributes dynamically. The action attribute specifies the URL where form data should be sent when submitted, while the method attribute determines the HTTP method used for submission (GET, POST, or dialog). Using the action Property The action property allows you to get or set the form's action attribute value. Syntax // Get action attribute let actionValue = document.getElementById('formID').action; // Set action attribute document.getElementById('formID').action = 'newURL'; ...

Read More

Sibling of a list element in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 15-Mar-2026 6K+ Views

In JavaScript, you can find sibling elements using DOM traversal properties. Siblings are elements that share the same parent element and exist at the same level in the HTML structure. Available Properties JavaScript provides several properties to navigate between sibling elements: nextSibling - Returns the next node (including text and comment nodes) nextElementSibling - Returns the next element sibling only previousSibling - Returns the previous node (including text and comment nodes) previousElementSibling - Returns the previous element sibling only Syntax node.nextSibling node.nextElementSibling node.previousSibling node.previousElementSibling Key Difference: nextSibling vs nextElementSibling ...

Read More
Showing 16711–16720 of 61,297 articles
Advertisements