Articles on Trending Technologies

Technical articles with clear explanations and examples

What are JavaScript Identifiers?

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 5K+ Views

JavaScript identifiers are names given to variables, functions, classes, objects, and other entities in your code. They work similarly to identifiers in other programming languages like C, C++, and Java, but have specific rules you must follow. What are Identifiers? An identifier is simply a name that you create to reference a variable, function, or other code element. Here are some examples of valid identifiers: // Valid variable identifiers let userName = "John"; let age = 25; let _privateVar = "hidden"; let $element = "jQuery style"; let camelCaseVariable = "standard naming"; console.log(userName); console.log(age); console.log(_privateVar); ...

Read More

How to set the opacity level for an element with JavaScript?

Sharon Christine
Sharon Christine
Updated on 15-Mar-2026 1K+ Views

Use the opacity property in JavaScript to set the opacity level for any element. The opacity value ranges from 0 (completely transparent) to 1 (completely opaque). Syntax element.style.opacity = "value"; Where value is a number between 0 and 1: 0 - Completely transparent (invisible) 0.5 - 50% transparent 1 - Completely opaque (default) Example: Basic Opacity Control #box { width: 450px; ...

Read More

HTML5 SVG css3 transition on fill not working when there is external link

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

CSS3 transitions on SVG fill properties don't work when links are in a visited state due to browser security restrictions. Browsers limit styling capabilities for visited links to prevent privacy attacks. The Problem When an SVG element is inside a visited link, CSS transitions on the fill property are disabled by the browser. This is a security feature to prevent websites from detecting your browsing history. Solution: Adding Random Query Parameters The most effective solution is to add a random query parameter to your URLs, making each link appear "unvisited" to the browser.

Read More

The HashTable Class in Javascript

Sai Subramanyam
Sai Subramanyam
Updated on 15-Mar-2026 283 Views

A HashTable (Hash Map) is a data structure that stores key-value pairs using a hash function to compute array indices. This implementation uses chaining to handle collisions, where multiple values can be stored at the same index using arrays. Complete HashTable Implementation class HashTable { constructor() { this.container = []; // Populate the container with empty arrays // which can be used to add more elements in // cases of collisions for (let i = ...

Read More

PreventDefault( ) vs Return false in JavaScript?

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

In JavaScript, when handling events, you often need to prevent the default browser behavior. The two common approaches are preventDefault() and return false, but they work differently. The preventDefault() method stops only the default action, while return false stops both the default action and event propagation. Key Differences preventDefault() return false Method available on event objects JavaScript statement that can be used anywhere Stops only the default behavior Stops default behavior AND event propagation Allows event to continue bubbling up Stops event bubbling and function execution ...

Read More

Is there an elegant way of passing an object of parameters into a function?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 180 Views

Passing an object of parameters to a function provides flexibility and improves code readability. This technique allows you to avoid positional parameters and makes your functions more maintainable. Using Object Destructuring (Recommended) The most elegant approach uses ES6 destructuring to extract object properties directly in the function parameter: Object Parameters Example Passing Object Parameters to Functions Calculate Sum ...

Read More

Remove and add new HTML Tags with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 881 Views

JavaScript provides several methods to dynamically remove and add HTML elements to the DOM. You can hide/show existing elements or completely remove/create new elements using vanilla JavaScript or jQuery. Method 1: Using jQuery hide() and show() The simplest approach is using jQuery's hide() and show() methods to toggle element visibility: Hide/Show Elements Test JavaScript This content can be hidden and shown. ...

Read More

Check for illegal number with isNaN() in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 292 Views

In JavaScript, isNaN() function checks if a value is "Not a Number" (NaN). It's commonly used to validate numeric operations and detect illegal numbers in calculations. What is NaN? NaN stands for "Not a Number" and is returned when a mathematical operation fails or produces an undefined result, such as multiplying a string with a number. Syntax isNaN(value) Parameters value: The value to be tested. If not a number, JavaScript attempts to convert it before testing. Return Value Returns true if the value is NaN, false otherwise. Example: Detecting ...

Read More

Finding mistakes in a string - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 577 Views

We are required to write a JavaScript function that takes in two strings. The first string is some mistyped string and the second string is the correct version of this string. We can assume that the two strings we are getting as argument will always have the same length. We have to return the number of mistakes that exist in the first string by comparing it character by character with the correct version. Approach The solution involves iterating through both strings simultaneously and comparing each character at the same position. When characters don't match, we increment our ...

Read More

Thrice sum of elements of array - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 349 Views

We are required to write a JavaScript function that takes in an array of Numbers and returns a new array with elements as sum of three consecutive elements from the original array. For example, if the input array is: const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Then the output should be: const output = [3, 12, 21, 9]; The function groups elements in sets of three and calculates their sum: (0+1+2=3), (3+4+5=12), (6+7+8=21), and (9+0+0=9) for the remaining element. How It Works The ...

Read More
Showing 18111–18120 of 61,299 articles
Advertisements