Object Oriented Programming Articles

Page 84 of 589

What is the importance of _isEqual() method in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 1K+ Views

The _.isEqual() method from Underscore.js and Lodash libraries provides deep equality comparison for JavaScript objects. Unlike native JavaScript comparison operators, it performs value-based comparison rather than reference-based comparison. Why _.isEqual() is Important JavaScript's native equality operators (== and ===) only check if two objects are the same reference in memory, not if they have the same content. The _.isEqual() method solves this by performing deep comparison of object properties, regardless of property order. Syntax _.isEqual(object1, object2); It accepts two values as parameters and returns true if they are equivalent, false otherwise. Example: ...

Read More

What is the importance of _without() method in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 365 Views

The _.without() method is part of the Underscore.js library that creates a new array by excluding specified values from an original array. It performs case-sensitive matching and removes all occurrences of the specified values. Syntax _.without(array, *values) Parameters array - The source array to filter *values - One or more values to exclude from the array Return Value Returns a new array with the specified values removed, preserving the original array order. Example: Removing Numbers The following example removes multiple numeric values from an array: ...

Read More

Is it possible to change the HTML content in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 2K+ Views

Yes, it is possible to change HTML content using JavaScript. JavaScript provides DOM (Document Object Model) methods that can access and modify HTML elements. These methods, such as document.getElementById(), document.getElementsByTagName(), and others, allow you to dynamically update content in HTML tags like , , , etc. Common Methods to Change HTML Content The most frequently used properties for changing HTML content are: innerHTML - Changes the HTML content inside an element textContent - Changes only the text content (no HTML tags) innerText - Similar to textContent but respects styling Example 1: Changing Content with ...

Read More

What is the importance of _.union() method in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 1K+ Views

The _.union() method from the Underscore.js library creates a new array containing unique values from multiple input arrays. It performs a union operation, removing duplicates while preserving the original order of first occurrence. Syntax _.union(array1, array2, ...arrayN); Parameters array1, array2, ...arrayN: Two or more arrays to be combined. The method accepts any number of arrays as arguments. Return Value Returns a new array containing all unique values from the input arrays, maintaining the order of first occurrence. Example with Numbers In the following example, _.union() combines multiple arrays and removes ...

Read More

What is the use of _.size() method in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 696 Views

The _.size() method is part of the Underscore.js library and returns the number of elements in arrays, objects, and strings. It provides a consistent way to get the size of various data types. Syntax _.size(collection) Parameters collection: The array, object, or string to count elements from. Return Value Returns a number representing the count of elements in the collection. Example 1: Array Size Find the size of a numeric array using _.size(): var arr = [100, 62, 73, 534, 565]; document.write("Array size: ...

Read More

What is the importance of _.initial() function in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 555 Views

The _.initial() function is part of the Underscore.js library that returns all elements of an array except the last n elements. It's useful for removing elements from the end of an array without modifying the original array. Syntax _.initial(array, n); Parameters array - The input array from which to extract elements. n (optional) - Number of elements to exclude from the end. Default is 1. Return Value Returns a new array containing all elements except the last n elements. Example: Basic Usage ...

Read More

How to get the Width and Height of the screen in JavaScript?

Sai Teja Kotha
Sai Teja Kotha
Updated on 15-Mar-2026 10K+ Views

In this article, we are going to discuss how to get the width and height of the screen in JavaScript. JavaScript provides a window.screen object that contains information regarding the user's screen. The information includes height and width, and also many other features like color depth and pixel density. To find the height and width of the screen you need to use the following read-only properties: screen.height − This property returns the height of the screen in pixels. screen.width − This property returns the width of the screen in pixels. ...

Read More

How to modify an array value of a JSON object in JavaScript?

Sai Teja Kotha
Sai Teja Kotha
Updated on 15-Mar-2026 8K+ Views

In JavaScript, JSON objects are regular JavaScript objects that can contain arrays. Modifying array values within these objects is straightforward using array indexing or array methods. When working with JSON objects containing arrays, you can access and modify array elements just like you would with any JavaScript array, using bracket notation or array methods. Syntax To modify an array value in a JSON object: // Direct index assignment jsonObject.arrayProperty[index] = newValue; // Using array methods jsonObject.arrayProperty.push(newValue); jsonObject.arrayProperty.splice(index, 1, newValue); Method 1: Direct Index Assignment The simplest way to modify an array ...

Read More

How to concatenate two strings so that the second string must concatenate at the end of first string in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 1K+ Views

String concatenation is the process of joining two or more strings together to create a new string. In JavaScript, there are several methods to concatenate strings, with the second string being appended at the end of the first string. Using concat() Method The concat() method joins the calling string with the provided string arguments to create a new string. The original strings remain unchanged since strings in JavaScript are immutable. Syntax concat(str1) concat(str1, str2) concat(str1, str2, ... , strN) Parameters Parameter Description strN One or more strings to ...

Read More

How to get the application name and version information of a browser in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 2K+ Views

JavaScript provides a navigator object that contains information about the browser. To get the application name and version information, the navigator object provides navigator.appName and navigator.appVersion properties respectively. Application Name of the Browser The navigator.appName property returns the application name of the browser. However, due to historical reasons, most modern browsers (Chrome, Firefox, Safari, Edge) return "Netscape" regardless of their actual name. Example document.write("Application Name: " + navigator.appName); Output Application Name: Netscape Browser Version Information The navigator.appVersion property provides ...

Read More
Showing 831–840 of 5,881 articles
« Prev 1 82 83 84 85 86 589 Next »
Advertisements