Javascript Articles

Page 274 of 534

With JavaScript Regular Expression find a non-whitespace character.

Daniol Thomas
Daniol Thomas
Updated on 15-Mar-2026 508 Views

To find a non-whitespace character in JavaScript regular expressions, use the \S metacharacter. This matches any character that is not a space, tab, newline, or other whitespace character. Syntax \S // Matches any non-whitespace character \S+ // Matches one or more non-whitespace characters \S* // Matches zero or more non-whitespace characters Example: Finding Non-Whitespace Characters JavaScript Regular Expression ...

Read More

With JavaScript RegExp search a carriage return character.

Ayyan
Ayyan
Updated on 15-Mar-2026 759 Views

To find carriage return characters with JavaScript Regular Expression, use the \r metacharacter. This pattern matches the carriage return character (ASCII code 13) in strings. Syntax /\r/ Example: Finding Carriage Return Position The following example shows how to search for a carriage return character and return its position in the string: JavaScript Regular Expression ...

Read More

What is availHeight property in JavaScript?

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

The screen.availHeight property returns the available height of the user's screen in pixels, excluding areas occupied by the taskbar, dock, or other system interfaces. Syntax screen.availHeight Return Value Returns a number representing the available screen height in pixels, excluding system UI elements like taskbars. Example Here's how to use the screen.availHeight property to get the available screen height: Screen Available Height ...

Read More

Match any string containing a sequence of two to three p's.

Akshaya Akki
Akshaya Akki
Updated on 15-Mar-2026 159 Views

To match any string containing a sequence of two to three p's with JavaScript RegExp, use the p{2, 3} quantifier. This pattern matches exactly 2 or 3 consecutive occurrences of the letter "p". Syntax /p{2, 3}/flags Where {2, 3} specifies the minimum (2) and maximum (3) number of consecutive p's to match. Example: Matching 2-3 Consecutive p's JavaScript Regular Expression var str = "apple pepper hippopotamus p programming"; ...

Read More

Match any single character outside the given set.

Rama Giri
Rama Giri
Updated on 15-Mar-2026 150 Views

To match any single character outside the given set with JavaScript RegExp, use the [^...] metacharacter. The caret ^ inside square brackets creates a negated character class that matches any character NOT in the specified set. Syntax /[^characters]/flags Where characters are the characters you want to exclude from matching. Example: Matching Characters Outside a Set JavaScript Regular Expression var myStr = "Welcome!"; var ...

Read More

How to return a number indicating the Unicode value of the character?

Alankritha Ammu
Alankritha Ammu
Updated on 15-Mar-2026 430 Views

The charCodeAt() method returns a number indicating the Unicode value of the character at the given index. Unicode code points range from 0 to 1, 114, 111. The first 128 Unicode code points are a direct match of the ASCII character encoding. Syntax string.charCodeAt(index) Parameters index − An integer between 0 and 1 less than the length of the string; if unspecified, defaults to 0. Return Value Returns a number representing the Unicode code point of the character at the specified index. If the index is ...

Read More

What will happen if a semicolon is misplaced in JavaScript?

Srinivas Gorla
Srinivas Gorla
Updated on 15-Mar-2026 270 Views

If a semicolon is misplaced in JavaScript, it can lead to unexpected behavior due to Automatic Semicolon Insertion (ASI). JavaScript automatically inserts semicolons at the end of statements, which can sometimes cause logical errors when semicolons are placed incorrectly. Common Semicolon Misplacement Issues The most common problem occurs when a semicolon is accidentally placed after control flow statements like if, for, or while. Example: Semicolon After if Statement var val1 = 10; ...

Read More

How to return a random number between 0 and 199 with JavaScript?

Rama Giri
Rama Giri
Updated on 15-Mar-2026 464 Views

To return a random number between 0 and 199, use the JavaScript Math.random() and Math.floor() methods together. How It Works Math.random() generates a random decimal between 0 (inclusive) and 1 (exclusive). To get integers from 0 to 199: Multiply by 200 to get range 0 to 199.999... Use Math.floor() to round down to nearest integer Example // Generate random number between 0-199 let randomNum = Math.floor(Math.random() * ...

Read More

What is the usage of onpageshow event in JavaScript?

Nitya Raut
Nitya Raut
Updated on 15-Mar-2026 250 Views

The onpageshow event triggers in JavaScript when a user navigates to a web page, including when the page loads for the first time or when returning from the browser's back/forward cache (bfcache). Syntax // HTML attribute // Event listener window.addEventListener('pageshow', function(event) { // Handle page show }); Example: Basic Usage Here's how to implement the onpageshow event using HTML attribute: On first visit, a welcome message is visible. ...

Read More

What is the usage of onpagehide event in JavaScript?

Akshaya Akki
Akshaya Akki
Updated on 15-Mar-2026 516 Views

The onpagehide event triggers in JavaScript when a user leaves the page and navigates away. This occurs during page refresh, clicking links, closing the browser tab, or navigating to another page. Syntax // HTML attribute // JavaScript event listener window.addEventListener('pagehide', function(event) { // Code to execute }); Example: Basic Usage Here's how to implement the onpagehide event using an HTML attribute: Navigate away from this page to see the alert! ...

Read More
Showing 2731–2740 of 5,340 articles
« Prev 1 272 273 274 275 276 534 Next »
Advertisements