Programming Scripts Articles

Page 12 of 33

How -Infinity is converted to Number in JavaScript?

Monica Mona
Monica Mona
Updated on 15-Mar-2026 297 Views

In JavaScript, -Infinity is a special numeric value representing negative infinity. When converted using the Number() method, it remains -Infinity since it's already a valid number type. Understanding -Infinity -Infinity is a built-in JavaScript constant that represents the mathematical concept of negative infinity. It's already of type "number", so converting it with Number() simply returns the same value. -Infinity Conversion Converting -Infinity to Number var myVal = -Infinity; ...

Read More

What is the role of ctrlKey Mouse Event in JavaScript?

Govinda Sai
Govinda Sai
Updated on 15-Mar-2026 300 Views

The ctrlKey mouse event property is a boolean value that indicates whether the CTRL key was pressed when a mouse event occurred. This property is available on all mouse events like click, mousedown, mouseup, etc. Syntax event.ctrlKey Return Value true - if the CTRL key was pressed during the mouse event false - if the CTRL key was not pressed during the mouse event Example The following example demonstrates how to detect if the CTRL key is pressed when clicking on an element: ...

Read More

What is the role of shiftKey Mouse Event in JavaScript?

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 287 Views

The shiftKey property is a boolean property of mouse events that indicates whether the Shift key was pressed when the mouse event occurred. This property is commonly used to modify the behavior of mouse interactions based on keyboard modifiers. Syntax event.shiftKey Return Value The shiftKey property returns: true - if the Shift key was pressed during the mouse event false - if the Shift key was not pressed during the mouse event Example: Basic shiftKey Detection Here's how to detect if the Shift key ...

Read More

How to set the shape of the border of the top-right corner with JavaScript?

Fendadis John
Fendadis John
Updated on 15-Mar-2026 273 Views

To set the shape of the border of the top-right corner in JavaScript, use the borderTopRightRadius property. This property allows you to create rounded corners by specifying the radius value. Syntax element.style.borderTopRightRadius = "value"; The value can be specified in pixels (px), percentages (%), or other CSS units like em or rem. Example Here's how to dynamically change the top-right border radius using JavaScript: #box { ...

Read More

How [ ] is converted to Boolean in JavaScript?

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 221 Views

In JavaScript, an empty array [] is considered a truthy value when converted to Boolean. This might seem counterintuitive, but it follows JavaScript's type coercion rules for objects. Converting [] to Boolean Use the Boolean() method to explicitly convert an empty array to Boolean: Convert [] to Boolean var myVal = []; document.write("Boolean: " + Boolean(myVal)); ...

Read More

What will happen when { } is converted to String in JavaScript?

Arushi
Arushi
Updated on 15-Mar-2026 191 Views

In JavaScript, when an empty object {} is converted to a string, it becomes "[object Object]". This happens because JavaScript calls the object's toString() method during string conversion. How Object to String Conversion Works JavaScript follows these steps when converting an object to a string: First, it calls the object's toString() method For plain objects, toString() returns "[object Object]" This is the default string representation for all plain objects Example: Converting Empty Object to String Convert {} to String ...

Read More

Which is the event when the browser window is resized in JavaScript?

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 206 Views

The resize event fires when the browser window is resized. You can listen for this event using window.addEventListener() or the onresize attribute to detect window size changes. The resize Event The resize event is triggered whenever the browser window dimensions change. This includes maximizing, minimizing, or manually dragging the window borders. Method 1: Using addEventListener() Window Resize Event Window Resize Detector Resize your browser window to see the dimensions update: ...

Read More

How to search the value of the type attribute of a link in JavaScript?

Jennifer Nicholas
Jennifer Nicholas
Updated on 15-Mar-2026 257 Views

To search or retrieve the value of the type attribute of a link in JavaScript, you can use the type property of the anchor element. This attribute specifies the MIME type of the linked resource. Syntax element.type Example: Getting Type Attribute Value Qries var x = document.getElementById("qriesid").type; document.write("Value of the type attribute: " + x); ...

Read More

How to set all the background properties in one declaration with JavaScript DOM?

Swarali Sree
Swarali Sree
Updated on 15-Mar-2026 176 Views

To set multiple background properties in JavaScript, use the background property. This shorthand property allows you to set background color, image, position, repeat, and other background-related properties in a single declaration. Syntax element.style.background = "color image repeat attachment position"; Background Property Values The background shorthand can include the following properties in any order: background-color: Sets the background color background-image: Sets the background image using url() background-repeat: Controls image repetition (repeat, no-repeat, repeat-x, repeat-y) background-position: Sets image position (left, right, center, top, bottom, or pixel values) background-attachment: Controls scrolling behavior (scroll, fixed) ...

Read More

How to search the querystring part of the href attribute of an area in JavaScript?

Ramu Prasad
Ramu Prasad
Updated on 15-Mar-2026 203 Views

To get the querystring from the href attribute of an area element, use the search property. This property returns the query portion of the URL, including the question mark. Syntax areaElement.search Return Value Returns a string containing the query portion of the href URL, including the leading question mark (?). Returns an empty string if no query parameters exist. Example ...

Read More
Showing 111–120 of 328 articles
« Prev 1 10 11 12 13 14 33 Next »
Advertisements