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
Web Development Articles
Page 364 of 801
How null is converted to Number in JavaScript?
In JavaScript, null is a primitive value that represents the intentional absence of any object value. When null is converted to a number, it becomes 0. This article explores various methods to convert null to a number in JavaScript. Using Number() Method Using Logical OR (||) Using the ~~ operator Using Ternary Operator Using arithmetic operations Using the Number() Method The Number() method is the most straightforward way to convert null to a number. It explicitly converts null to 0. Syntax Number(null) Example ...
Read MoreHow to attach one or more drop-shadows to the box with JavaScript?
To attach one or more drop shadows to a box with JavaScript, you can use the boxShadow style property. You can specify the shadow's horizontal offset, vertical offset, blur radius, spread radius, and color. Syntax Following is the syntax to add one or more drop shadows to the box with JavaScript: element.style.boxShadow = "offset-x offset-y blur-radius spread-radius color"; Parameters The boxShadow property accepts the following parameters: offset-x − Horizontal offset of the shadow. Positive values create a shadow on the right side, negative values on the left ...
Read MoreHow to return the position of the element relative to floating objects in JavaScript?
This tutorial teaches us how to return the position of the element relative to floating objects in JavaScript. To set the relative position or to get or return the relative position we are going to use the 'clear' property of JavaScript which is defined under the style property of an object. The CSS clear property controls how an element behaves next to floating elements. It can have values like 'left', 'right', 'both', or 'none'. When an element has the clear property set, it will move down to avoid overlapping with floated elements on the specified side. Syntax ...
Read MoreHow to set the inward offsets of the image border with JavaScript?
In this tutorial, we will learn how to set the inward offsets of the image border with JavaScript. An image can be set in the border as a border image using CSS properties. The border image can be set using different parameters. To set the inward offsets of the image border, use the borderImageSlice property in JavaScript. We will see two different approaches to setting up the inward offsets of the image border with JavaScript − The borderImageSlice Property The setProperty Method Using the borderImageSlice Property ...
Read MoreHow null is converted to Boolean in JavaScript?
In JavaScript, null is a primitive value that represents an intentional absence of any object value. When converting null to Boolean, it always evaluates to false because null is considered a falsy value in JavaScript. Understanding Falsy Values In JavaScript, null is one of the falsy values along with undefined, 0, "" (empty string), NaN, and false. All falsy values convert to false when used in Boolean contexts. Using the Boolean() Function The Boolean() function converts any value to its Boolean equivalent. For null, it always returns false. Syntax Boolean(null) Example ...
Read MoreHow is NaN converted to Boolean in JavaScript?
In JavaScript, NaN (Not a Number) is a special numeric value that represents an invalid number. When converted to Boolean, NaN is always considered a falsy value. This article explores three methods to convert NaN to Boolean. Using the Boolean() Function Using the !! Operator Using the NOT Operator and isNaN() Method Understanding NaN as a Falsy Value In JavaScript, NaN is one of the falsy values (along with false, 0, "", null, and undefined). This means it always converts to false in Boolean contexts. Using the Boolean() Function The Boolean() function converts ...
Read MoreHow -Infinity is converted to String in JavaScript?
In JavaScript, -Infinity is a special numeric value that represents negative infinity. When we need to convert it to a string, we can use the String() method or the toString() method. The -Infinity value typically results from mathematical operations like dividing a negative number by zero or when a calculation exceeds the minimum representable number in JavaScript. Syntax The String() method converts any JavaScript value to a string representation: String(value) Where value is any JavaScript value. The method returns the string representation of that value. Using String() Method The most reliable ...
Read MoreHow to set the style of the right border with JavaScript?
In this tutorial, we will learn to set a style of the right border with JavaScript. To set the style of the right border in JavaScript, use the borderRightStyle property. Set the style of the right border using this property. We can apply borders to an element from any side or all sides. We can customize that border on any side. Every edge of a border has a specific property that can use only for that edge. We can provide three parameters like style, color, and width for creating a border. CSS is used to do such tasks. But, ...
Read MoreHow to set the width of the right border with JavaScript?
This tutorial will teach us to set the width of the right border with JavaScript. To set the width of the right border, use the borderRightWidth property. Set the width of the right border using this property. We can also apply the borderWidth to set the right border. Borders are used on various elements on a webpage. They display the boundaries of an element. We can apply the borders to all sides of an element. There are different properties to set different sides of a border. For a static border, generally, CSS is used. But to change it dynamically, ...
Read MoreHow to find the coordinates of the cursor with JavaScript?
In this tutorial, we will learn how to find the coordinates of the mouse cursor with JavaScript. We need to determine the X and Y coordinates (horizontal and vertical positions) of the cursor on the screen when mouse events occur. JavaScript provides us with two essential properties to get the coordinates of the mouse cursor when events are triggered: Using event.clientX Property Using event.clientY Property Using event.clientX Property The event.clientX property returns the horizontal position (X-coordinate) of the cursor relative to the browser's viewport when an event is ...
Read More