Javascript Articles

Page 425 of 534

JavaScript Immediately Invoked Function Expressions (IIFE)

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 205 Views

An Immediately Invoked Function Expression (IIFE) is a JavaScript function that executes immediately after it has been defined. This pattern is useful for creating isolated scope and avoiding global namespace pollution. Syntax (function() { // Code here runs immediately })(); // Alternative syntax (function() { // Code here runs immediately }()); Basic IIFE Example IIFE Example JavaScript IIFE Demo ...

Read More

JavaScript JSON Arrays

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 334 Views

JSON arrays are ordered lists of values enclosed in square brackets. In JavaScript, you can access and manipulate JSON arrays just like regular JavaScript arrays. Syntax { "arrayName": ["value1", "value2", "value3"] } Basic JSON Array Structure Here's how a JSON object with an array property looks: JSON Array Example let obj = { ...

Read More

JavaScript JSON HTML

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 313 Views

Generating HTML from JSON data is a common task in web development. You can fetch JSON data from APIs and dynamically create HTML elements to display the information. Note − JSONPlaceholder is a fake Online REST API for Testing and Prototyping. Example: Creating HTML Table from JSON JSON to HTML Example body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; ...

Read More

JavaScript - know the value of GET parameters from URL

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 282 Views

To extract GET parameters from a URL in JavaScript, you can use the built-in URL and URLSearchParams APIs. These provide a clean way to parse query strings from URLs. Using URL and URLSearchParams The URL constructor creates a URL object, and its searchParams property gives access to query parameters: GET Parameters Example body { ...

Read More

JavaScript lastIndex Property

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 151 Views

The lastIndex property in JavaScript is used with regular expressions to track the position where the next search will begin. It only works with the global (g) flag and automatically updates after each match. Syntax regexObject.lastIndex How lastIndex Works The lastIndex property starts at 0 and updates to the position after each match when using exec() or test() with the global flag. JavaScript lastIndex Property Finding Multiple Matches with lastIndex let text = "The king bought an expensive ring."; let regex ...

Read More

JavaScript Let

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 216 Views

The JavaScript let keyword, introduced in ES6 (2015), allows us to declare block-scoped variables. Unlike var, variables declared with let are only accessible within the block where they are defined. Block Scope with let Variables declared with let are confined to their block scope and cannot be accessed outside of it. JavaScript Let Example JavaScript Let Block Scope Test Block Scope ...

Read More

JavaScript Location protocol Property

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 239 Views

The location.protocol property in JavaScript returns the protocol scheme of the current URL, including the colon (:). This property is useful for determining whether a page is loaded over HTTP, HTTPS, or other protocols. Syntax location.protocol Return Value Returns a string representing the protocol scheme of the URL, including the trailing colon. Common values include: "https:" - Secure HTTP protocol "http:" - Standard HTTP protocol "file:" - Local file protocol "ftp:" - File Transfer Protocol Example ...

Read More

JavaScript multiline Property

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 208 Views

The JavaScript multiline property is a read-only property of regular expression objects that returns true if the 'm' modifier (multiline flag) has been set, and false otherwise. The 'm' flag changes the behavior of ^ and $ anchors to match at line breaks within the string. Syntax regexp.multiline Return Value Returns a boolean value: true if the 'm' flag is set false if the 'm' flag is not set Example: Checking multiline Property ...

Read More

JavaScript Numbers example

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 189 Views

JavaScript has a single number type that represents both integers and floating-point numbers. Unlike other languages, JavaScript doesn't distinguish between different numeric types. Number Types in JavaScript All numbers in JavaScript are stored as 64-bit floating-point values, following the IEEE 754 standard. This means you can work with both whole numbers and decimals seamlessly. JavaScript Numbers body { ...

Read More

JavaScript Promises

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

Promises in JavaScript allow us to handle asynchronous operations where the value is not known in advance when the promise is being created. A promise can have three states: pending, fulfilled, and rejected. Promise States A promise represents an asynchronous operation and can be in one of three states: Pending: Initial state, neither fulfilled nor rejected Fulfilled: The operation completed successfully Rejected: The operation failed Creating a Basic Promise Here's how to create a simple promise: ...

Read More
Showing 4241–4250 of 5,340 articles
« Prev 1 423 424 425 426 427 534 Next »
Advertisements