Object Oriented Programming Articles

Page 95 of 589

JavaScript - Get the text of a span element

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

In JavaScript, you can get the text content of a span element using several methods. The most common approaches are innerHTML, textContent, and innerText. Methods to Get Span Text There are three main properties to retrieve text from a span element: innerHTML - Gets HTML content including tags textContent - Gets plain text content (recommended) innerText - Gets visible text content Example: Getting Span Text Get Span Text ...

Read More

JavaScript global Property

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 309 Views

The global property in JavaScript returns true or false depending on whether the 'g' (global) modifier is set in a regular expression pattern. Syntax regexPattern.global Return Value Returns a boolean value: true - if the 'g' flag is set false - if the 'g' flag is not set Example: Checking Global Flag JavaScript Global Property JavaScript Global Property Example ...

Read More

JavaScript Immediately Invoked Function Expressions (IIFE)

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 218 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 339 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 325 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 287 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 169 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 221 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 252 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 216 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
Showing 941–950 of 5,881 articles
« Prev 1 93 94 95 96 97 589 Next »
Advertisements