Programming Scripts Articles

Page 11 of 33

TypedArray.buffer property in JavaScript

Samual Sam
Samual Sam
Updated on 15-Mar-2026 108 Views

The buffer property of TypedArray instances provides access to the underlying ArrayBuffer object that stores the binary data for the typed array. Syntax typedArray.buffer Return Value Returns the ArrayBuffer object that backs the TypedArray instance. Example JavaScript Example var buffer = new ArrayBuffer(156); var float32 = new Float32Array(buffer); document.write("Buffer byte length: " + float32.buffer.byteLength); ...

Read More

What is the usage of onfocus event in JavaScript?

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

The onfocus event is triggered when an HTML element receives focus, typically when a user clicks on an input field or navigates to it using the Tab key. This event is commonly used to provide visual feedback or perform actions when users interact with form elements. Syntax // HTML attribute // JavaScript event listener element.onfocus = function() { /* code */ }; element.addEventListener('focus', function() { /* code */ }); Example: Basic onfocus Implementation Click on the input field to see the onfocus effect: ...

Read More

TypedArray.byteLength property in JavaScript

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 128 Views

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 More

What is the usage of oninput event in JavaScript?

Sai Nath
Sai Nath
Updated on 15-Mar-2026 442 Views

The oninput event occurs whenever the value of an input element changes. Unlike onchange, which fires only when the element loses focus, oninput triggers immediately as the user types, making it ideal for real-time validation and live search functionality. Syntax // HTML attribute // JavaScript property element.oninput = function() { /* code */ }; // Event listener element.addEventListener('input', function() { /* code */ }); Basic Example oninput Example Type something below: ...

Read More

TypedArray.byteOffset property in JavaScript

Samual Sam
Samual Sam
Updated on 15-Mar-2026 114 Views

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 More

What is the usage of oninvalid event in JavaScript?

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 335 Views

The oninvalid event is triggered when a form field fails HTML5 validation constraints. It fires before form submission when an field with validation attributes (like required, pattern, etc.) contains invalid data. Syntax element.oninvalid = function() { // Handle invalid input }; // Or in HTML Basic Example Here's how to use oninvalid to show custom validation messages: Enter Name: ...

Read More

What is the usage of onreset event in JavaScript?

Anjana
Anjana
Updated on 15-Mar-2026 451 Views

The onreset event is triggered when a form is reset using a reset button or the reset() method. This event allows you to execute JavaScript code when users clear form data. Syntax // form elements // Or using addEventListener form.addEventListener('reset', functionName); Example: Basic onreset Event onreset Event Example function resetFunct() { alert("The form was ...

Read More

What is the usage of onsearch event in JavaScript?

Abhinanda Shri
Abhinanda Shri
Updated on 15-Mar-2026 421 Views

The onsearch event triggers when a user interacts with a search input field by pressing ENTER or clicking the "x" (clear) button. This event only works with elements and provides a convenient way to handle search operations. Syntax // Or using addEventListener element.addEventListener("search", myFunction); Example Here's how to implement the onsearch event to capture user search input: OnSearch Event Example Write what you want to search below and press "ENTER" or click the "x" to clear: ...

Read More

Which event occurs in JavaScript when an element's content is cut?

V Jyothi
V Jyothi
Updated on 15-Mar-2026 194 Views

The oncut event occurs when an element's content is cut using Ctrl+X or the right-click context menu. This event is commonly used with input fields, textareas, and other editable elements to track when users cut text. Syntax element.oncut = function() { // Code to execute when content is cut }; // Or using addEventListener element.addEventListener('cut', function(event) { // Code to execute when content is cut }); Example: Basic oncut Event Cut Event Example ...

Read More

What is the role of clientX Mouse Event in JavaScript?

Nancy Den
Nancy Den
Updated on 15-Mar-2026 473 Views

The clientX property returns the horizontal (x-axis) coordinate of the mouse pointer relative to the current viewport when a mouse event occurs. Unlike other coordinate properties, clientX is measured from the left edge of the browser's visible area, not including scrollbars. Syntax event.clientX Return Value Returns a number representing the horizontal pixel position of the mouse pointer relative to the viewport's left edge. Example: Getting Mouse Coordinates on Click clientX Mouse Event ...

Read More
Showing 101–110 of 328 articles
« Prev 1 9 10 11 12 13 33 Next »
Advertisements