Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Javascript Articles
Page 302 of 534
What does "use strict" do in JavaScript, and what is the reasoning behind it?
In this tutorial, we will learn what "use strict" does in JavaScript and why it's important for writing safer code. The "use strict" directive enables strict mode in JavaScript, which was introduced in ECMAScript 5 (ES5). It enforces stricter parsing and error handling, helping developers catch common mistakes and write more secure code. What is Strict Mode? Strict mode changes both syntax and runtime behavior. It eliminates some JavaScript silent errors by changing them into throw errors, fixes mistakes that make it difficult for JavaScript engines to perform optimizations, and prohibits some syntax likely to be defined ...
Read MoreUsage of border-right-width property in CSS
The border-right-width property controls the thickness of an element's right border. It only works when a border style is defined. Syntax border-right-width: value; Values Value Description thin Thin border (usually 1px) medium Medium border (usually 3px) thick Thick border (usually 5px) length Custom width (px, em, rem, etc.) Example with Different Widths .box { ...
Read MoreHow to define a JavaScript function using Function() Constructor?
The Function() constructor expects any number of string arguments. The last argument is the body of the function - it can contain arbitrary JavaScript statements, separated from each other by semicolons. Syntax new Function([arg1[, arg2[, ...argN]], ] functionBody) Parameters arg1, arg2, ...argN: Names to be used by the function as formal argument names (optional). functionBody: A string containing the JavaScript statements comprising the function definition. Example: Basic Function Creation var func = new Function("x", "y", "return ...
Read MoreChange the color of the left border with CSS
The border-left-color property in CSS allows you to change the color of an element's left border independently from other borders. This property is useful when you want to create visual emphasis or design accents on specific sides of an element. Syntax border-left-color: color-value; Parameters The property accepts various color values: Color names: red, blue, green, etc. Hex values: #FF0000, #00FF00, etc. RGB values: rgb(255, 0, 0) HSL values: hsl(0, 100%, 50%) Example p.demo { ...
Read MoreHow to replace string using JavaScript RegExp?
In this tutorial, we will explore how to replace a particular substring in a string using regular expressions in JavaScript. Sometimes we may want to replace a recurring substring in a string with something else. In such cases, regular expressions can be beneficial. Regular expressions are basically a pattern of characters that can be used to search different occurrences of that pattern in a string. Regular expressions make it possible to search for a particular pattern in a stream of characters and replace it easily. For example, consider the regular expression /ab*c/ which denotes that we are looking for ...
Read MoreSet a border between two lines with CSS
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 MoreHow to write a Regular Expression in JavaScript to remove spaces?
To remove spaces from strings in JavaScript, regular expressions provide a powerful and flexible solution. The most common approach uses the /\s/g pattern with the replace() method. Basic Syntax string.replace(/\s/g, '') Where: \s - matches any whitespace character (spaces, tabs, newlines) g - global flag to replace all occurrences '' - empty string replacement Example: Removing All Spaces var str = "Welcome to Tutorialspoint"; document.write("Original: " + str); // Removing all spaces var result = str.replace(/\s/g, ''); document.write("After removing spaces: " + result); ...
Read MoreThe set border that looks as though it is carved into the page
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 MoreWrite a Regular Expression to remove all special characters from a JavaScript String?
To remove all special characters from a JavaScript string, you can use regular expressions with the replace() method. The most common approach is using the pattern /[^\w\s]/g which matches any character that is not a word character or whitespace. Syntax string.replace(/[^\w\s]/g, '') Regular Expression Breakdown The pattern /[^\w\s]/g works as follows: [^...] - Negated character class (matches anything NOT in the brackets) \w - Word characters (a-z, A-Z, 0-9, _) \s - Whitespace characters (spaces, tabs, newlines) g - Global flag (replace all occurrences) Example: Basic Special Character Removal ...
Read MoreSet Inset border with CSS
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