Articles on Trending Technologies

Technical articles with clear explanations and examples

How to set the stack order of a positioned element in JavaScript?

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

In this tutorial, we shall learn to set the stack order of a positioned element in JavaScript. To set the stack order, we can use the style zIndex property. Let's first check what the stack order is. The stack order says the order in which the DOM elements are displayed. This is the element's position on the z-axis. Now, what is a positioned element? A positioned element has relative, absolute, fixed, or static positions. Why do we need to go for the stack order? Elements might overlap and look clumsy when positioned; therefore, we go for the ...

Read More

Not able to get the value of radio select setting dynamically in AngularJS

Krantik Chavan
Krantik Chavan
Updated on 15-Mar-2026 253 Views

When working with radio buttons in AngularJS within loops (like ng-repeat), you need to use $index to create unique model bindings for each row. Without it, all radio buttons share the same model and interfere with each other. Problem Radio buttons without proper indexing share the same ng-model, causing unexpected behavior where selecting one affects others. Solution: Using $index Add [$index] to your ng-model to create unique bindings for each iteration: India US Complete Example ...

Read More

How to access an object value using variable key in JavaScript?

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

In this article we are going to discuss how to access an object value using variable key in JavaScript. An object value can be accessed by a Dot Notation and a Bracket Notation. To get the object value through a variable key, the value or expression inside the bracket notation must match with the existing key name, then it returns a value. The bracket notation, unlike the dot notation can be used with variables. If we are using a variable with bracket notation, the variable must reference a string. Let's understand this concept better with the help of ...

Read More

How to deserialize a JSON into Javascript object?

Aman Kumar
Aman Kumar
Updated on 15-Mar-2026 3K+ Views

Serialization is the process of converting an object such that it is transferable over the network. In JavaScript usually we serialize an Object into the JSON (JavaScript Object Notation) format. To deserialize a JSON string back into a JavaScript object, we use the JSON.parse() method. This method takes a JSON string and converts it into a JavaScript object or array that we can work with in our code. JavaScript object notation is commonly used to exchange data with web servers and REST APIs. The data we receive from a web server is always a string. To use this ...

Read More

JavaScript lastIndex Property

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 174 Views

The lastIndex property in JavaScript is used with regular expressions to track the position where the next search will begin. It only works with the global (g) flag and automatically updates after each match. Syntax regexObject.lastIndex How lastIndex Works The lastIndex property starts at 0 and updates to the position after each match when using exec() or test() with the global flag. JavaScript lastIndex Property Finding Multiple Matches with lastIndex let text = "The king bought an expensive ring."; let regex ...

Read More

JavaScript : Why does % operator work on strings? - (Type Coercion)

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 461 Views

Let's say we have a code snippet that produces some surprising results. First, the modulo operator works with strings (unexpectedly). Second, concatenation of two strings produces awkward results. We need to explain why JavaScript behaves this way through type coercion. Problem Code const numStr = '127'; const result = numStr % 5; const firstName = 'Armaan'; const lastName = 'Malik'; const fullName = firstName + + lastName; console.log('modulo result:', result); console.log('full name:', fullName); modulo result: 2 full name: ArmaanNaN What is Type Coercion? Type coercion is JavaScript's automatic conversion of ...

Read More

How to check if every property on object is the same recursively in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 504 Views

When working with nested objects in JavaScript, you might need to check if all leaf values (final non-object values) are identical. This requires a recursive approach to traverse through all nested levels and compare the actual values at the end of each branch. For example, in this object: const obj = { a: 1, b: 1, c: { aa: 1 } }; The function should return true because all leaf values equal 1, even though one is ...

Read More

Strip quotes with JavaScript to convert into JSON object?

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

When dealing with JSON strings that have escaped quotes or extra quote wrapping, you need to clean them before parsing. This article shows how to strip unwanted quotes and convert the cleaned string into a JavaScript object. The Problem Sometimes JSON data comes with extra quotes or escaped quote characters that prevent direct parsing. Here's a common scenario where a JSON string is wrapped in extra quotes and has doubled internal quotes: var studentDetails = `"{""name"": ""John"", ""subjectName"": ""Introduction To JavaScript""}"`; console.log("Original string:"); console.log(studentDetails); Original string: "{""name"": ""John"", ""subjectName"": ""Introduction To JavaScript""}" ...

Read More

Find indexes of multiple minimum value in an array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 665 Views

Suppose we have an array of numbers like this − const arr = [1, 2, 3, 4, 1, 7, 8, 9, 1]; Suppose we want to find the index of the smallest element in the array i.e. 1 above. For this, we can simply use − const min = Math.min.apply(Math, arr); const ind = arr.indexOf(min); The above code will successfully set ind to 0, which indeed is correct. But what we want to achieve is that if there are more than one minimum elements in the array, like in the ...

Read More

How to compare two numbers in JavaScript?

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

In this tutorial, we will learn to compare two numbers in JavaScript. Whether you're a competitive coder or application developer, you'll often need to compare numbers and perform operations based on the comparison results. Many programmers think we can only compare numbers using equality operators, but we can also use less than () operators for comprehensive comparisons. Using the Strict Equality Operator (===) JavaScript has two equality operators: loose equality (==) and strict equality (===). The strict equality operator compares both value and data type, making it more reliable for number comparisons. Syntax let ...

Read More
Showing 16931–16940 of 61,297 articles
Advertisements