Programming Articles

Page 888 of 2547

Describe pass by value and pass by reference in JavaScript?

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

JavaScript passes data to functions in two ways: pass by value for primitives (numbers, strings, booleans) and pass by reference for objects and arrays. Understanding this distinction is crucial for avoiding unexpected behavior in your code. Pass by Value In pass by value, a function receives a copy of the variable's value. Changing this copy inside the function doesn't affect the original variable. JavaScript primitives (numbers, strings, booleans, null, undefined) are always passed by value. Example let a = 1; let change = (val) ...

Read More

Difference between Hibernate and Eclipse link

Himanshu shriv
Himanshu shriv
Updated on 15-Mar-2026 2K+ Views

Hibernate and EclipseLink are both Object-Relational Mapping (ORM) frameworks that implement the Java Persistence API (JPA) specification. While they serve the same fundamental purpose of mapping Java objects to relational databases, they have distinct differences in implementation and features. What is Hibernate? Hibernate is the most popular JPA implementation, developed by Red Hat. It provides robust ORM capabilities and includes additional features beyond the standard JPA specification. Hibernate has been widely adopted in enterprise applications due to its maturity and extensive documentation. What is EclipseLink? EclipseLink is an open-source JPA implementation developed by the Eclipse Foundation. ...

Read More

How to freeze an Object in JavaScript?

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

In JavaScript, Object.freeze() makes an object immutable by preventing modifications to its properties. Once frozen, you cannot add, delete, or modify properties of the object. Syntax Object.freeze(obj) Parameters obj: The object to freeze. Returns the same object that was passed to the function. How Object.freeze() Works When an object is frozen: New properties cannot be added Existing properties cannot be removed Existing property values cannot be changed The object's prototype cannot be changed Example: Basic Object Freezing // Create an object with properties ...

Read More

How to count a number of words in given string in JavaScript?

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

Counting words in a JavaScript string requires handling various whitespace scenarios like multiple spaces, leading/trailing spaces, and newlines. Using regular expressions provides an effective solution. The Challenge Strings can contain irregular spacing that affects word counting: Leading and trailing spaces Multiple consecutive spaces between words Newlines with spaces Empty strings Step-by-Step Approach Step 1: Remove Leading and Trailing Spaces Use regex to eliminate spaces at the start and end of the string: str.replace(/(^\s*)|(\s*$)/gi, ""); Step 2: Reduce Multiple Spaces to Single Space Replace consecutive spaces with a ...

Read More

How to submit an HTML form using JavaScript?

Abhishek
Abhishek
Updated on 15-Mar-2026 18K+ Views

In this tutorial, we will learn how to submit an HTML form using JavaScript. JavaScript provides multiple approaches to handle form submission, from direct programmatic submission to validation-based submission with user feedback. We will discuss two main methods for submitting HTML forms: Using the Form submit() Method Using Manual Validation Let us explore both methods with practical examples. Using the Form submit() Method The submit() method programmatically submits a form without requiring user interaction with the submit button. This method takes no parameters and returns no value—it ...

Read More

Explain in detail about Mark and Sweep algorithm in JavaScript?

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

Mark and Sweep Algorithm The Mark and Sweep algorithm is JavaScript's primary garbage collection method that identifies objects "which are unreachable" rather than objects "which are no longer needed". This algorithm is an improvement over the Reference-counting algorithm and solves the circular reference problem. How Mark and Sweep Works The algorithm operates in three important steps: Root Identification: The algorithm starts from "roots" - global variables accessible in the code. In browsers, the window object acts as the primary root. Marking Phase: The algorithm traverses from roots to find ...

Read More

How to clone an object in JavaScript?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 15-Mar-2026 5K+ Views

An object is said to be an entity which has properties and types in it. Example, consider a Person as an object and it has properties like height, weight, age and salary. In the similar way JavaScript also have objects and their defined properties. An object in JavaScript is a complicated data type where it can store various data types in it. Let's consider this example below: const employee = { ...

Read More

Difference between shift() and pop() methods in Javascript

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 599 Views

The shift() method removes the element at the first index (index 0) and shifts all remaining elements down by one position, then returns the removed value. If the array is empty, it returns undefined. The pop() method removes the last element from an array and returns that element. This method changes the length of the array. Syntax array.shift() // Removes first element array.pop() // Removes last element Example: Comparing shift() and pop() let fruits = ['apple', 'mango', 'orange', 'kiwi']; let fruits2 = ['apple', 'mango', 'orange', 'kiwi']; ...

Read More

How to add a number and a string in JavaScript?

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

In JavaScript, when you use the + operator with a number and a string, JavaScript performs concatenation instead of mathematical addition. This is because the presence of a string changes the operation from addition to string concatenation. How It Works JavaScript follows these rules when using the + operator: Number + Number: Mathematical addition String + Number: String concatenation (number is converted to string) Number + String: String concatenation (number is converted to string) Example var a = 5 + 5; ...

Read More

How to style background image to no repeat with JavaScript DOM?

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

In this tutorial, we will learn to style the background image to no repeat with JavaScript DOM. To style the background image to no repeat with JavaScript, use the backgroundRepeat property. It allows you to set whether the background image repeats or not on a page. The use of images in the background really makes the page attractive. But before using the image in the background, one must completely understand the properties used to set the images as the background. Otherwise, it will create problems like not showing the full image in the background, repeating the image horizontally or ...

Read More
Showing 8871–8880 of 25,466 articles
« Prev 1 886 887 888 889 890 2547 Next »
Advertisements