Front End Technology Articles

Page 443 of 652

How to determine if JavaScript object is an event?

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

In JavaScript, distinguishing between regular objects and event objects is important when handling user interactions and DOM events. An event object contains information about an event that occurred, such as mouse clicks or keyboard presses, while regular objects store data as properties and methods. JavaScript events are actions that happen in the browser, like clicking a button or loading a page. When these events occur, JavaScript creates event objects that contain details about what happened. Let's explore two reliable methods to check if an object is an event. Using the target Property Event objects have a target ...

Read More

What is the difference between jQuery and JavaScript?

Kiran Kumar Panigrahi
Kiran Kumar Panigrahi
Updated on 15-Mar-2026 2K+ Views

Both JavaScript and jQuery serve the same overarching objective of making webpages more interactive and dynamic. They give websites a sense of vibrancy. People may ask why there is a need for two distinct concepts if they serve the same function. Read through this article to find out how jQuery differs from JavaScript. What is JavaScript? JavaScript is a lightweight programming language that is used most often as a component of webpages. Its webpage implementations enable client-side script to interact with the user and create dynamic sites. It is a programming language that is interpreted and can handle ...

Read More

How to handle bind an event using JavaScript?

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

In this tutorial, we will learn how to bind events using JavaScript. Events are actions or occurrences triggered by the browser or users. There are various types of events that represent different activities. For example, if a user clicks on a button, it triggers a "click" event. Similarly, when a webpage finishes loading, it triggers a "load" event. An Event Listener is a program that continuously listens for events to occur. Event Handlers are functions that execute when an event occurs. JavaScript binds events to their respective event handlers using the addEventListener method. Binding Events with addEventListener ...

Read More

Is it possible to change values of the array when doing foreach() in javascript?

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

Yes, it is possible to change array values during forEach() iteration in JavaScript. Unlike some programming languages where modifying arrays during iteration is restricted, JavaScript's forEach() allows you to modify the original array by using the array parameter or accessing the array directly by index. The forEach Method The forEach() method executes a provided function once for each array element. It passes three parameters to the callback function: the current element value, the element's index, and the array itself. You can use the array parameter to modify elements during iteration. Syntax array.forEach(function(value, index, array) { ...

Read More

Get div height with vanilla JavaScript

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

The HTML element is a container used to group and style other HTML elements. Getting the height of a div element is a common task in JavaScript, and there are several properties available to achieve this, each measuring different aspects of the element's dimensions. Using offsetHeight The offsetHeight property returns the total height of an element including content, padding, border, and scrollbar (if present). Syntax element.offsetHeight The offsetHeight includes: offsetHeight = content height + padding + border + scrollbar height ...

Read More

How to get image data url in JavaScript?

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

To obtain an image data URL in JavaScript, you can use several approaches depending on your source. The most common methods involve the Canvas API's toDataURL() method and the FileReader API for uploaded files. Using Canvas toDataURL() Method The toDataURL() method converts canvas content into a base64-encoded data URL. By default, it creates a PNG image, but you can specify JPEG format and quality. canvas.toDataURL(); // PNG format (default) canvas.toDataURL('image/jpeg'); // ...

Read More

Different techniques for copying objects in JavaScript

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 432 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 699 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 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
Showing 4421–4430 of 6,519 articles
« Prev 1 441 442 443 444 445 652 Next »
Advertisements