Articles on Trending Technologies

Technical articles with clear explanations and examples

How to do string interpolation in JavaScript?

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 18K+ Views

String interpolation in JavaScript is a process in which expressions and variables are embedded directly into strings. This is achieved using template literals (backticks) with placeholder syntax ${}, making code more readable and maintainable than traditional string concatenation. Template literals use backticks (`) instead of quotes and allow expressions to be embedded using ${expression} syntax. This enables dynamic content insertion, mathematical calculations, and complex expressions within strings. Syntax `string text ${expression} more text` The expression inside ${} can be variables, function calls, mathematical operations, or any valid JavaScript expression that returns a value. ...

Read More

Different techniques for copying objects in JavaScript

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 429 Views

In JavaScript, objects are collections of key-value pairs. The properties of the object are the keys and are denoted with strings. The value of the key is the value of the property of the given object. Types of Object Copying There are 2 types of copying objects: shallow copy and deep copy. Shallow Copy In shallow copy, an object is copied at the top level only. If the object contains nested objects, only the references are copied, not the actual nested objects. Example Following is an example of shallow copy using Object.assign(): ...

Read More

Difference between .extend() / .assign() and .merge() in Lodash library.

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 1K+ Views

The Lodash library is a JavaScript utility library that provides helpful functions for working with arrays, strings, objects, numbers, and more. This article compares three important object merging methods: Object.assign(), _.extend(), and _.merge(). The Object.assign() Method Object.assign() is a native JavaScript method that performs shallow copying of enumerable properties from source objects to a target object. It modifies the target object and returns it. Syntax Object.assign(target, source1, source2, ...) Example var employee = { emp_name: "Abdul Rawoof", company: "Tutorials Point", salary: 18000, ...

Read More

What is the use of .stack property in JavaScript?

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 691 Views

The .stack property in JavaScript provides detailed information about errors, including the error type, message, and call stack trace. It shows where the error occurred and the sequence of function calls that led to the error. The stack property is available on Error objects and contains a string representation of the stack trace. This is extremely useful for debugging as it shows the exact location and path of execution when an error occurs. Format of Error Stack The stack trace format typically displays: First line: Error type and message Subsequent lines: Function call stack with file ...

Read More

How many values does javascript have for nothing?

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 774 Views

JavaScript has two primitive values that represent "nothing": null and undefined. Both indicate the absence of a meaningful value, but they have distinct purposes and behaviors. Undefined A variable is undefined when it has been declared but not assigned a value, or when a function doesn't explicitly return anything. JavaScript automatically assigns undefined in these cases. Example 1 - Variable Declaration When a variable is declared but not assigned a value: var str; console.log('The value of given variable is:', str); The value of given variable is: undefined Example 2 ...

Read More

What is the most efficient way to deep clone an object in JavaScript?

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 1K+ Views

In JavaScript, objects are reference types, meaning simple assignment creates a reference to the original object, not a copy. Deep cloning creates a completely independent copy with separate memory allocation for nested objects and arrays. Understanding Deep vs Shallow Cloning Shallow cloning copies only the top-level properties, while deep cloning recursively copies all nested objects. Methods like spread operator and Object.assign() only perform shallow copies. Using JSON.parse() and JSON.stringify() (Most Common) The most efficient and widely-used approach combines JSON.stringify() to convert the object to a string, then JSON.parse() to create a new object from that string. ...

Read More

How to duplicate Javascript object properties in another object?

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 2K+ Views

In JavaScript, objects are collections of key-value pairs where properties are identified by string keys. There are several ways to duplicate object properties from one object to another, each with different characteristics for handling nested objects and references. Using Spread Operator (...) The spread operator creates a shallow copy of an object by spreading its enumerable properties into a new object. It's represented by three dots (...) and is the most modern and readable approach. Example 1 This example demonstrates how the spread operator copies objects in JavaScript: var employee = { ...

Read More

Window.onload vs onDocumentReady in javascript

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 6K+ Views

In JavaScript, window.onload and $(document).ready() are two different methods for executing code when a page loads, each with distinct timing and behavior. Window.onload The window.onload method executes after the entire web page has completely loaded, including all DOM elements, stylesheets, images, and other external resources. It only allows one function assignment — subsequent assignments will overwrite previous ones. Syntax window.onload = function() { // Code executes after everything loads }; window.onload = (event) => { // Arrow function syntax }; Example: Window.onload Behavior ...

Read More

How to find operating system in the client machine using JavaScript?

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 2K+ Views

The operating system of the client machine can be detected using JavaScript navigator properties. This is useful for providing platform-specific functionality or displaying system information to users. Using navigator.appVersion The navigator.appVersion property returns a string containing browser and operating system information. This method allows you to parse the version string to identify the OS. Syntax navigator.appVersion Example 1: Detecting Operating System This example demonstrates how to detect the client's operating system using navigator.appVersion: Click to get the operating system ...

Read More

Disadvantages of using innerHTML in JavaScript

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 3K+ Views

The innerHTML property in JavaScript allows you to get or set the HTML content inside an element. While convenient, it comes with several significant disadvantages that developers should consider when manipulating the DOM. What is innerHTML? The innerHTML property represents the HTML content inside an element. It allows you to read or modify the HTML markup within a selected DOM element. Original content let container ...

Read More
Showing 19251–19260 of 61,297 articles
Advertisements