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
Articles by Nikitha N
Page 2 of 6
How to set the page-break behavior after an element with JavaScript?
Use the pageBreakAfter property in JavaScript to control page-break behavior after an element. This property is essential for formatting printed documents and print previews. Note: Changes are only visible when printing the page or viewing print preview (Ctrl+P). Syntax element.style.pageBreakAfter = "value"; Property Values Value Description auto Default - automatic page breaks always Forces page break after element avoid Avoids page break after element left Forces page break to left page right Forces page break to right page ...
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 MoreHow to write JavaScript Regular Expression for multiple matches?
To find multiple matches in JavaScript, use the global flag (g) with regular expressions. The exec() method can be called repeatedly to find all matches in a string. Syntax let regex = /pattern/g; let matches; while ((matches = regex.exec(string)) !== null) { // Process each match } Example: Extracting URL Parameters This example extracts all demo parameters from a URL query string: var url = 'https://www.example.com/new.html?ui=7&demo=one&demo=two&demo=three'; var a = document.createElement('a'); a.href = url; var demoRegex = /(?:^|[&;])demo=([^&;]+)/g; var matches; var demo = []; ...
Read MoreWhich is the JavaScript RegExp to find any alternative text?
To match any of the specified alternatives in JavaScript, use the alternation operator | within parentheses. This pattern allows you to find multiple possible text options in a single regular expression. Syntax (option1|option2|option3) The pipe symbol | acts as an OR operator, matching any one of the alternatives listed within the parentheses. Example Here's how to find alternative text patterns using JavaScript RegExp: JavaScript Regular Expression var myStr = "one, ...
Read MoreIncrease or decrease the size of a font with CSS
The font-size property in CSS controls the size of text elements. You can use various units and keywords to set font sizes, from absolute values like pixels to relative keywords like "small" and "large". Syntax font-size: value; Available Values The font-size property accepts several types of values: Absolute keywords: xx-small, x-small, small, medium, large, x-large, xx-large Relative keywords: smaller, larger Length units: pixels (px), points (pt), ems (em), rems (rem) Percentage: relative to parent element's font size Example: ...
Read MoreAdd or subtract space between the letters that make up a word with CSS
To add or subtract space between the letters that make up a word, use the letter-spacing CSS property. This property controls the horizontal spacing between characters in text. Syntax letter-spacing: normal | length | initial | inherit; Property Values normal - Default spacing between letters length - Specific spacing value (px, em, rem, etc.) initial - Sets to default value inherit - Inherits from parent element Example: Adding Letter Spacing ...
Read MoreWhat is for each...in a statement in JavaScript?
The for each...in loop was a non-standard JavaScript feature that iterated over the values of object properties. However, it has been deprecated and removed from modern JavaScript engines. Important: The for each...in statement is deprecated and no longer supported. Use modern alternatives like for...of, Object.values(), or forEach() instead. Syntax (Deprecated) The original syntax was: for each (variablename in object) { statement or block to execute } Why It Was Deprecated The for each...in statement was: Non-standard and only supported in Firefox Confusing because it mixed concepts from ...
Read MoreWhat is a block statement in JavaScript?
A block statement groups zero or more statements within curly braces {}. In languages other than JavaScript, it is known as a compound statement. Block statements are commonly used with control structures like if, for, and while. Syntax Here's the basic syntax: { // List of statements statement1; statement2; // ...more statements } Block Scoping with var vs let/const Variables declared with var do not have block scope - they are function-scoped or globally-scoped. However, let and const are block-scoped. ...
Read MoreHow to check if a string has a certain piece of text in JavaScript?
JavaScript provides several methods to check if a string contains a specific piece of text. While the older search() method works, modern approaches like includes() are more intuitive and widely used. Using includes() Method (Recommended) The includes() method returns true if the string contains the specified text, false otherwise. let str = "Tutorialspoint: Free Video Tutorials"; let searchText = "Free Video"; if (str.includes(searchText)) { document.write("Contains"); } else { document.write("Does not contain"); } Contains Using search() Method The search() method returns the ...
Read MoreDefine skew transforms along with x axis using CSS
The CSS skewX() transform function distorts an element by skewing it along the x-axis (horizontally). This creates a slanted effect where the element appears tilted to the left or right while maintaining its height. Syntax transform: skewX(angle); Where angle is specified in degrees (deg) or radians (rad). Positive values skew the element to the left, while negative values skew it to the right. Example: Skewing Element Along X-Axis The following example demonstrates how to apply a skew transform along the x-axis − div ...
Read More