Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Programming Scripts Articles
Page 9 of 33
How -Infinity is converted to Boolean in JavaScript?
In JavaScript, -Infinity is considered a truthy value and converts to true when converted to Boolean. This might be surprising since negative infinity seems conceptually "negative, " but JavaScript treats all non-zero numbers (including infinities) as truthy. Using Boolean() Constructor The Boolean() constructor explicitly converts values to their boolean equivalent: Convert -Infinity to Boolean var myVal = -Infinity; document.write("Boolean: ...
Read MoreHow to work with document.embeds in JavaScript?
The document.embeds property in JavaScript provides access to all elements in an HTML document. It returns an HTMLCollection containing all embed elements, which is useful for managing embedded content like videos, audio files, or plugins. Syntax document.embeds document.embeds.length document.embeds[index] document.embeds.namedItem(name) Basic Example Here's how to count and access embed elements in a document: Document Embeds Example ...
Read MoreHow to search the alternate text of an image-map area in JavaScript?
To search the alternate (alt) text of an image-map area in JavaScript, use the alt property. This property allows you to access or modify the alternative text that describes the image map area for accessibility purposes. Syntax // Get alt text let altText = areaElement.alt; // Set alt text areaElement.alt = "new alt text"; Example: Accessing Alt Text of Image Map Area ...
Read MoreHow to convert Binary to Decimal in JavaScript?
In this tutorial, we will learn to convert binary to decimal in JavaScript. A binary number is a string of '0' and '1' digits, representing numbers in base 2 format used in digital electronics. Here are two different methods to convert binary numbers to decimal: Using the parseInt() Method The parseInt() method can extract numbers from strings and accepts a base parameter, making it perfect for binary conversion. Syntax let binary = "0101"; let decimal = parseInt(binary, 2); Parameters binary − The binary number as a string base − The ...
Read MoreHow to search and display the pathname part of the href attribute of an area with JavaScript?
To get the pathname part of the href attribute of an area in JavaScript, use the pathname property. This property extracts just the path portion from a URL, excluding the protocol, domain, and query parameters. Syntax areaElement.pathname Example You can try to run the following code to display the pathname part of an area element's href attribute. ...
Read MoreHow to work with document.images in JavaScript?
The document.images property in JavaScript provides access to all elements in a document. It returns an HTMLCollection containing all image elements, allowing you to count, access, and manipulate images programmatically. Syntax document.images document.images.length document.images[index] document.images.namedItem(name) Properties and Methods The document.images collection provides: length - Returns the number of images in the document [index] - Access image by numeric index (0-based) namedItem() - Access image by name or id attribute Example: Counting Images ...
Read MoreWhat will happen when 0 is converted to Number in JavaScript?
Use the Number() method in JavaScript to convert values to Number type. When converting 0 to Number, it remains 0 since it's already a valid number. Basic Conversion Converting 0 to Number returns 0, as zero is already a number: Convert 0 to Number var myVal = 0; document.write("Number: " + Number(myVal)); ...
Read MoreWhat is the role of scrollX property in JavaScript?
The scrollX property in JavaScript returns the number of pixels the document has been scrolled horizontally from the left edge of the viewport. It's equivalent to the older pageXOffset property and is read-only. Syntax let horizontalScroll = window.scrollX; Return Value Returns a number representing the horizontal scroll position in pixels. The value is 0 when the document is not scrolled horizontally. Example: Basic scrollX Usage .content { ...
Read MoreWhat will happen when 1 is converted to Boolean in JavaScript?
In JavaScript, when the number 1 is converted to Boolean, it becomes true. This is because 1 is considered a "truthy" value in JavaScript's type conversion system. Understanding Truthy and Falsy Values JavaScript has specific rules for Boolean conversion. The number 1 (and all non-zero numbers) are truthy values, meaning they convert to true. Example: Converting 1 to Boolean Convert 1 to Boolean var myVal = 1; document.write("Boolean: " ...
Read MoreWhat is the usage of an abort event in JavaScript?
The abort event fires when the loading of a media resource is aborted, typically for images, videos, or audio elements. This event occurs when the user navigates away from the page or explicitly stops the loading process before it completes. When the abort Event Occurs The abort event is triggered in several scenarios: User navigates away from the page while an image is loading Loading is interrupted by clicking a link or refreshing the page Network connection is lost during resource loading The loading process is programmatically canceled Example: Basic abort Event Handler ...
Read More