Web Development Articles

Page 360 of 801

What are the three types of errors I can expect in my JavaScript script?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 615 Views

In this tutorial, let us discuss the three types of errors we can expect in our JavaScript code. Errors are statements that block the execution of the program. During the compilation and execution of JavaScript programs, three types of errors can occur: syntax errors, runtime errors, and logical errors. Syntax Errors Syntax errors are the most common errors that occur when the JavaScript engine cannot understand the code due to incorrect syntax. These errors happen during the parsing phase before code execution begins. For example, using a semicolon instead of a colon in an object declaration ...

Read More

Find digits not between the brackets using JavaScript Regular Expressions?

Sravani Alamanda
Sravani Alamanda
Updated on 15-Mar-2026 261 Views

In JavaScript, regular expressions with negated character classes [^0-9] are used to find characters that are NOT digits. The caret ^ inside square brackets creates a negated character class, matching any character except those specified. Regular expressions (RegExp) are powerful pattern-matching tools introduced in ES1 and supported by all modern browsers. They're commonly used for string validation, search operations, and text manipulation. Syntax The syntax for matching non-digits is: new RegExp("[^0-9]") // or simply /[^0-9]/ With modifiers for global matching: new RegExp("[^0-9]", "g") // or simply /[^0-9]/g ...

Read More

Find the non-digit character with JavaScript Regular Expression

Sravani Alamanda
Sravani Alamanda
Updated on 15-Mar-2026 2K+ Views

In this tutorial, we will learn to find non-digit characters using JavaScript regular expressions. The \D metacharacter matches any character that is not a digit (0-9), including letters, spaces, and special characters. RegExp is an object that specifies patterns used for search and replace operations on strings or input validation. RegExp was introduced in ES1 and is fully supported by all browsers. Syntax The syntax for matching non-digit characters is: new RegExp("\D") // Constructor syntax /\D/ // Literal syntax (recommended) ...

Read More

Find a form feed character with JavaScript RegExp.

Sravani Alamanda
Sravani Alamanda
Updated on 15-Mar-2026 1K+ Views

Form feed character is a page breaking ASCII control character commonly used for page separators. When you want to insert a page break, text editors can use this form feed. It is defined as \f and has an ASCII code value of 12 or 0x0c. RegExp is an object that specifies the pattern used to perform search and replace operations on strings or for input validation. RegExp was introduced in ES1 and is fully supported by all browsers. Now, we will check how to find the form feed (\f) character in given text using RegExp. Syntax ...

Read More

For the Hosts Locale how to convert a string to uppercase letters in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 409 Views

In this tutorial, we will learn how to convert a string to uppercase letters for the host's locale in JavaScript. While using a locale language to write for a website, we might have to convert the sentence from lowercase to uppercase without changing the structure of the string. Using the toLocaleUpperCase() Method In JavaScript, we use the toUpperCase() method as well as the toLocaleUpperCase() to change the letters of a string to uppercase. Although both methods give similar output, the toLocaleUpperCase() is used primarily for local languages and handles locale-specific character mappings correctly. Syntax We ...

Read More

How to load the next URL in the history list in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 870 Views

In this tutorial, we will learn to load the next page in the history list in JavaScript. The Window object in JavaScript accesses the window in the browser. This object contains many properties and methods required to do the tasks. The Window object also retrieves the information from the browser window. There is a history stack in every browser that saves the pages visited by the user. To access this history stack, we can use the history object that is the property of the Window object. By accessing the history from the browser, we can go to the ...

Read More

Which event occurs in JavaScript when a dragged element is dropped?

Swarali Sree
Swarali Sree
Updated on 15-Mar-2026 247 Views

The ondrop event occurs when a dragged element is successfully dropped on a valid drop target. This event is part of the HTML5 Drag and Drop API and must work together with ondragover to enable dropping functionality. How Drag and Drop Works The drag and drop process involves several events: ondragstart - When dragging begins ondragover - When dragged element is over a drop target ondrop - When element is dropped on target ondragend - When dragging operation ends Key Requirements For ondrop to work properly: The drop target must handle ondragover and ...

Read More

How to load the previous URL in the history list in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 7K+ Views

In this tutorial, we will learn to load the previous page in the history list in JavaScript. The Window object in JavaScript accesses the window in the browser. This object contains many properties and methods required to do the tasks. The Window object also retrieves the information from the browser window. There is a history stack in every browser that saves the pages visited by the user. To access this history stack, we can use the history object that is the property of the Window object. By accessing the history from the browser, we can go to the ...

Read More

How to get the number of the internet host port for the current page in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 792 Views

In this tutorial, we will learn to get the number of internet host port for the current page in JavaScript. The Port number is a 16-bit unique identifier used by network protocols. Port numbers range from 0-65535 and help servers identify specific processes or services. Each port number has its own identity and purpose in network communication. Following are the methods by which we can get the port number of the internet host: Using the location.port Property Using the URL interface Using the location.port Property ...

Read More

How to return the id of the first image in a document with JavaScript?

Kumar Varma
Kumar Varma
Updated on 15-Mar-2026 597 Views

To return the id of the first image in a document, use the document.images property in JavaScript. This property returns a collection of all image elements in the document. Syntax document.images[0].id How It Works The document.images collection contains all elements in the document, indexed starting from 0. To get the first image's id, access document.images[0].id. Example Here's a complete example showing how to get the id of the first image: ...

Read More
Showing 3591–3600 of 8,010 articles
« Prev 1 358 359 360 361 362 801 Next »
Advertisements