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
HTML Articles
Page 129 of 151
What is the role of ctrlKey Mouse Event in JavaScript?
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 MoreTypedArray.byteLength property in JavaScript
The byteLength property of the TypedArray object represents the length of the TypedArray in bytes. It is a read-only property that returns the size of the underlying buffer used by the typed array. Syntax typedArray.byteLength Example: Basic Usage JavaScript Example var buffer = new ArrayBuffer(156); var float32 = new Float32Array(buffer); document.write("ByteLength: " + float32.byteLength); ...
Read MoreWhat is the role of shiftKey Mouse Event in JavaScript?
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 MoreTypedArray.byteOffset property in JavaScript
The byteOffset property of TypedArray returns the offset (in bytes) from the start of the ArrayBuffer where the typed array begins. Syntax typedArray.byteOffset Parameters This is a property, not a method, so it takes no parameters. Return Value Returns a number representing the byte offset from the beginning of the ArrayBuffer. Example 1: TypedArray at Buffer Start JavaScript byteOffset Example var buffer = new ArrayBuffer(16); ...
Read MoreHow to set the shape of the border of the top-right corner with JavaScript?
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 MoreHow [ ] is converted to Boolean in JavaScript?
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 MoreWhat will happen when { } is converted to String in JavaScript?
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 MoreHow to return a random number between 1 and 200 with JavaScript?
To return a random number between 1 and 200, use JavaScript's Math.random() and Math.floor() methods. How It Works Math.random() generates a decimal between 0 (inclusive) and 1 (exclusive). To get integers from 1 to 200: Multiply by 200 to get 0 to 199.999... Use Math.floor() to round down to 0-199 Add 1 to shift the range to 1-200 Example You can try to run the following code to return a random number in JavaScript. ...
Read MoreWhich is the event when the browser window is resized in JavaScript?
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 MoreHow to search the value of the type attribute of a link in JavaScript?
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