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 Abhishek
Page 5 of 7
What is Subtraction Operator (-) in JavaScript?
The subtraction operator (-) is a binary arithmetic operator in JavaScript that subtracts the right operand from the left operand. It requires two operands and returns the mathematical difference between them. The subtraction operator follows standard mathematical rules - if the first operand is larger, the result is positive; if smaller, the result is negative. Syntax let result = operand1 - operand2; Basic Examples console.log(9 - 5); // 4 (positive result) console.log(5 - 9); // -4 (negative result) console.log(10 - 10); // 0 (zero result) ...
Read MoreWhat is Unary Negation Operator (-) in JavaScript?
The Unary Negation Operator (-) converts its operand to a number and then negates it. It operates on a single operand and returns the negative value. Boolean values are converted to 0 or 1 before negation, and numbers in different bases are converted to decimal first. Syntax -operand The unary negation operator (-) precedes the operand to negate its value. Basic Examples Let's see how the unary negation operator works with different data types: ...
Read MoreWhat is Modulus Operator (%) in JavaScript?
The modulus operator (%) in JavaScript returns the remainder after dividing one number by another. It's also called the remainder operator and is commonly used in programming for tasks like checking if a number is even or odd. Syntax operand1 % operand2 Where operand1 is the dividend and operand2 is the divisor. The operation returns the remainder of the division. Basic Examples console.log(10 % 3); // 1 (10 ÷ 3 = 3 remainder 1) console.log(15 % 4); // 3 (15 ÷ 4 = 3 remainder 3) console.log(20 % 5); ...
Read MoreHow to use JavaScript to redirect a webpage after 5 seconds?
In this tutorial, we learn to use JavaScript to redirect a webpage after 5 seconds. To redirect a webpage after a delay, we use the setTimeout() method combined with window.location.href to set the destination URL. JavaScript provides two timing methods for delayed execution: setTimeout() for single execution and setInterval() for repeated execution. For page redirection, setTimeout() is the preferred method. To redirect a page we use the window.location.href property to change the current page URL: window.location.href = "https://example.com"; Using setTimeout() Method (Recommended) The setTimeout() method executes a function once after a specified delay. ...
Read MoreWhat is Multiplication Assignment Operator (*=) in JavaScript?
The multiplication assignment operator (*=) in JavaScript provides a shorthand way to multiply a variable by a value and assign the result back to the variable. Instead of writing a = a * b, you can simply use a *= b. Syntax operand1 *= operand2 // equivalent to: operand1 = operand1 * operand2 The multiplication assignment operator is a binary operator that multiplies the left operand by the right operand and stores the result in the left operand. Example 1: Basic Usage with Numbers Here's how the multiplication assignment operator works with numeric ...
Read MoreHow to find JavaScript function definition in Chrome?
When developing or debugging web applications, finding JavaScript function definitions in Chrome is essential. Chrome provides multiple methods to locate functions quickly and efficiently. This tutorial covers three primary methods for finding JavaScript functions in Google Chrome: Using Developer Tools Sources Panel Using Inspect Element Using View Page Source Using Developer Tools Sources Panel The Developer Tools Sources panel is the most powerful method for finding and debugging JavaScript functions. Steps to Use Developer Tools Step 1: Open Developer Tools ...
Read MoreHow to use text as background using CSS?
Text as background creates interesting visual effects where text appears behind other content. This technique uses CSS positioning and z-index to layer text elements, making them appear as decorative background elements rather than primary content. Syntax /* Method 1: Absolute positioning */ .background-text { position: absolute; z-index: -1; } /* Method 2: Pseudo elements */ .element::before { content: "Background Text"; position: absolute; z-index: -1; } Method 1: Using Absolute Positioned Elements This method ...
Read MoreHow to use font-feature-settings property in CSS?
The font-feature-settings property is used to control advanced typographic features in OpenType fonts. Advanced typographic features like swashes, small caps, and ligatures can be controlled using this CSS property. Syntax selector { font-feature-settings: "feature-tag" value; } Possible Values ValueDescription normalDefault value, uses the font's default settings "feature-tag"Four-character OpenType feature tag in quotes 1 or onEnables the specified feature 0 or offDisables the specified feature Common Feature Tags "smcp" − Small capitals "swsh" − Swashes "liga" − Common ligatures "dlig" − Discretionary ligatures "kern" − Kerning ...
Read MoreHow to use font-variant-settings property in CSS?
The CSS font-variant-settings property provides low-level control over OpenType font features, allowing you to enable or disable specific typographic features like ligatures, small capitals, and number styles. This property gives you fine-grained control over font rendering. Syntax selector { font-variant-settings: "feature" value; } Possible Values ValueDescription normalDefault value, equivalent to no feature settings "feature" valueOpenType feature tag with on (1) or off (0) value inheritInherits from parent element initialSets to default value Example 1: Enabling Small Capitals The following example demonstrates using the "smcp" feature to ...
Read MoreHow to set the size of specific flex-item using CSS?
In CSS, we can control the size of specific flex items using various flex properties. The CSS flexbox is used to create responsive layouts that adapt to different screen sizes by adjusting item dimensions and positioning. Syntax selector { flex-grow: number; flex-shrink: number; flex-basis: length | percentage | auto; flex: flex-grow flex-shrink flex-basis; } Key Flex Properties PropertyDescription flex-growControls how much a flex item should grow relative to other items flex-shrinkControls how much a flex item should ...
Read More