Javascript Articles

Page 423 of 534

JavaScript Const

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 347 Views

The JavaScript const declaration creates variables that cannot be reassigned to another value or redeclared later. It was introduced in ES2015 (ES6) and provides block scope like let but with immutable binding. Syntax const variableName = value; Basic const Example body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } Const Example Try ...

Read More

JavaScript Convert an array to JSON

Vivek Verma
Vivek Verma
Updated on 15-Mar-2026 2K+ Views

An array is a special object in JavaScript that stores multiple types of values, including integers, strings, and floats simultaneously. JSON (JavaScript Object Notation) is a lightweight data format used to represent structured data, commonly used for transmitting data between servers and web applications. In this article, we'll explore how to convert a JavaScript array into JSON format using the JSON.stringify() method. Understanding JSON.stringify() The JSON.stringify() method converts a JavaScript value or object into a JSON string. Since arrays are objects in JavaScript, we can pass an array as an argument to this method. Syntax ...

Read More

JavaScript – Getting Coordinates of mouse

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 527 Views

In JavaScript, you can get the coordinates of the mouse cursor using mouse event properties. The most common approach is to use the mousemove event listener along with event properties like clientX, clientY, pageX, and pageY. Mouse Coordinate Properties Different properties provide coordinates relative to different reference points: clientX, clientY - Coordinates relative to the viewport (visible browser window) pageX, pageY - Coordinates relative to the entire document (includes scrolled areas) screenX, screenY - Coordinates relative to the user's screen offsetX, offsetY - Coordinates ...

Read More

JavaScript encodeURI(), decodeURI() and its components functions

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 370 Views

JavaScript provides four essential functions for handling URI encoding and decoding. The encodeURI() function encodes complete URIs while preserving structural characters, whereas encodeURIComponent() encodes URI components including all special characters. Understanding the Functions The encodeURI() function encodes special characters in a URI except for reserved characters like , / ? : @ & = + $ # which are essential for URI structure. The encodeURIComponent() function encodes URI components by encoding all special characters including the reserved ones. The corresponding decode functions decodeURI() and decodeURIComponent() reverse the encoding process. Syntax encodeURI(uri) decodeURI(encodedURI) encodeURIComponent(uriComponent) decodeURIComponent(encodedURIComponent) ...

Read More

JavaScript Error message Property

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 266 Views

The message property of JavaScript Error objects contains a human-readable description of the error. It's automatically set when an error occurs and can also be customized when creating custom errors. Syntax error.message Example: Accessing Error Message JavaScript Error message Property body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 18px; ...

Read More

JavaScript Error name Property

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 221 Views

The name property of JavaScript Error objects identifies the type of error that occurred. It returns a string representing the error's name, which helps in debugging and error handling. Syntax error.name Common Error Names Different error types have specific names: ReferenceError - Variable or function not defined TypeError - Wrong data type used SyntaxError - Invalid syntax RangeError - Number out of range Example: Displaying Error Names Error Name Property ...

Read More

JavaScript Cursor property

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 229 Views

The JavaScript cursor property sets or returns the cursor type that will be displayed when hovering over an element. This property allows you to change the mouse cursor appearance dynamically using JavaScript. Syntax element.style.cursor = "cursorType"; Example: Changing Cursor on Button Click body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { ...

Read More

JavaScript DataView()

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 234 Views

The JavaScript DataView provides a low-level interface for reading and writing multiple number types in binary ArrayBuffer. You cannot manipulate ArrayBuffer directly without using DataView(). Syntax new DataView(buffer) new DataView(buffer, byteOffset) new DataView(buffer, byteOffset, byteLength) Parameters buffer - The ArrayBuffer to create a view for byteOffset - (Optional) Starting byte offset, default is 0 byteLength - (Optional) Number of bytes to include, default is buffer's length Basic Example DataView Example Run ...

Read More

How to make a fullscreen window with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 611 Views

The Fullscreen API allows you to display HTML elements in fullscreen mode. This is commonly used for videos, images, or interactive content that benefits from maximum screen real estate. Syntax element.requestFullscreen() // Standard element.webkitRequestFullscreen() // WebKit (Safari, Chrome) element.mozRequestFullScreen() // Firefox element.msRequestFullscreen() // IE/Edge Example: Video Fullscreen body { ...

Read More

How to draw on scroll using JavaScript and SVG?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 590 Views

Drawing on scroll using JavaScript and SVG creates an engaging animation effect where an SVG path gradually appears as the user scrolls down the page. This technique uses stroke-dasharray and stroke-dashoffset properties to control path visibility. How It Works The technique uses SVG's stroke-dasharray and stroke-dashoffset properties to hide the path initially, then gradually reveals it based on scroll position. The path length is calculated and used to synchronize the drawing with scroll progress. SVG Path Drawing Animation Initial State (Hidden) ...

Read More
Showing 4221–4230 of 5,340 articles
« Prev 1 421 422 423 424 425 534 Next »
Advertisements