Web Development Articles

Page 356 of 801

How to remove two parts of a string with JavaScript?

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 3K+ Views

This tutorial teaches us how to remove the text part between two parts of a string with JavaScript. We are given two ends that can be a string or a character and we need to remove the string lying in between them. We will use regular expressions with JavaScript's replace() method to accomplish this task. Syntax Here's the basic syntax for removing part of a string between two characters or sub-strings: var str = "your string here"; var final_str = str.replace(/(first_part).*?(second_part)/, '$1$2'); In the above syntax: first_part - The starting delimiter (string ...

Read More

Set a border between two lines with CSS

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 354 Views

Use the border-style property with double value to set a border with two lines. The double border style creates two solid lines with a gap between them, making it useful for highlighting content or creating visual separation. Syntax border-style: double; border-width: thickness; Example .no-border { border-width: 4px; border-style: ...

Read More

How to catch all JavaScript errors?

Saurabh Jaiswal
Saurabh Jaiswal
Updated on 15-Mar-2026 13K+ Views

To catch all JavaScript errors, we can use the window.onerror method which acts like a global try-catch statement. The onerror event handler was the first feature to facilitate error handling in JavaScript. The error event is fired on the window object whenever an exception occurs on the page. The onerror event handler provides three pieces of information to identify the exact nature of the error: Error message − The same message that the browser would display for the given error URL − The file in which the error occurred ...

Read More

How to catch syntax errors in JavaScript?

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

In this tutorial, we will learn how to catch syntax errors in JavaScript and handle them effectively. JavaScript throws various types of errors when we write incorrect code: ReferenceError when calling undefined variables, TypeError when trying to modify immutable values inappropriately, and SyntaxError when the code structure is invalid. What is Syntax Error? A SyntaxError occurs when JavaScript encounters code that violates the language's syntax rules. Unlike runtime errors, syntax errors are detected during the parsing phase, before the code executes. Common Causes of Syntax Errors Missing brackets: Unclosed parentheses (), braces ...

Read More

How can I get a JavaScript stack trace when I throw an exception?

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

This tutorial teaches us to get a JavaScript stack trace when we throw an exception. Usually, the developer uses the stack trace to identify the errors while executing the program's code. However, we use the stack trace to debug the program. Using the stack trace, we can get knowledge of any kind of exceptions, such as constructor error, naming error, etc., in our program, and we can correct them. Before we approach analyzing the error using the stack trace, we should know how to stack trace works. How does the call stack trace work? The stack ...

Read More

How to skip character in capture group in JavaScript Regexp?

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 1K+ Views

You cannot skip a character in a capture group. A match is always consecutive, even when it contains things like zero-width assertions. However, you can use techniques to extract specific parts while ignoring unwanted characters. Understanding the Problem When you need to match a pattern but only capture certain parts, you can use non-capturing groups (?:...) and capturing groups (...) strategically to ignore unwanted characters. Example: Extracting Username After Prefix The following example shows how to match a string with a prefix but only capture the username part: ...

Read More

The set border that looks as though it is carved into the page

Samual Sam
Samual Sam
Updated on 15-Mar-2026 146 Views

The CSS border-style property with the groove value creates a border that appears carved into the page, giving it a 3D inset effect. This style is useful for creating visual depth and making elements appear recessed. Syntax border-style: groove; Example Groove Border Example This paragraph has no border style applied. ...

Read More

How do you access the matched groups in a JavaScript regular expression?

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

This tutorial will teach us to access the matched groups in JavaScript regular expression. The regular expression is the sequence of the character, also called the RegEx, and it is useful to match specific patterns in the string. There can be more than one match for the specific pattern in the string. To get the occurrence of all matches, we have explained the different methods below in this tutorial. We will also see the various usage of the regular expression in this article. Use the 'g' flag while creating the Regex When we add 'g' as ...

Read More

How to set current time to some other time in JavaScript?

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

You cannot directly modify the system time with JavaScript since it uses the system's clock through the Date object. However, you can simulate different times by adjusting timezones or creating custom date objects with specific values. Method 1: Using Timezone Conversion You can display time for different timezones by calculating the offset from UTC: var date, utc, offset, singaporeTime; date = new Date(); ...

Read More

Set Inset border with CSS

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

To set inset border with CSS, use the border-style property with value inset. The inset border style creates a 3D effect that makes the element appear pressed into the page. Syntax border-style: inset; /* or for specific sides */ border-top-style: inset; border-right-style: inset; border-bottom-style: inset; border-left-style: inset; Example .no-border { border-width: 4px; border-style: ...

Read More
Showing 3551–3560 of 8,010 articles
« Prev 1 354 355 356 357 358 801 Next »
Advertisements