The border-bottom-style property defines the style of an element's bottom border. It accepts various values like solid, dashed, dotted, and more to create different visual effects. Syntax border-bottom-style: value; Available Values The property accepts the following values: none - No border (default) solid - A solid line dashed - A dashed line dotted - A dotted line double - Two solid lines groove - A 3D grooved border ridge - A 3D ridged border inset - A 3D inset border outset - A 3D outset border Example: Basic Usage ... Read More
JavaScript modules allow you to split code into separate files and share functionality between them using import and export statements. This promotes code reusability and better organization. Note: To run module examples, you need a localhost server since modules use CORS policy. Export Types There are two main ways to export from a module: Default Export: One main export per module Named Export: Multiple exports with specific names Default Export Example math.js (module file): // Default export - only one per module export default function add(a, b) { ... Read More
In JavaScript, infinity values represent numbers that exceed the maximum finite value. JavaScript provides built-in constants to handle positive and negative infinity values. JavaScript Infinity Constants JavaScript has two built-in constants for infinity values: Infinity or Number.POSITIVE_INFINITY - represents positive infinity -Infinity or Number.NEGATIVE_INFINITY - represents negative infinity Basic Example JavaScript Infinity Values JavaScript Infinity Values ... Read More
The new operator in JavaScript creates instances of user-defined objects or built-in object types that have constructor functions. When used with a constructor function, it creates a new object, sets up the prototype chain, and returns the newly created object. Syntax new constructor([arguments]) How the new Operator Works When you use the new operator, JavaScript performs these steps: Creates a new empty object Sets the object's prototype to the constructor's prototype Calls the constructor function with this pointing to the new object ... Read More
We have an array of strings each of which contain one or more numbers like this − const arr = ['di5aster', 'ca1amity', 'cod3', 'ho2me3', 'ca11ing']; We are required to write a sorting function that sorts this array in ascending order of the numbers present in the strings. The correct order will be − const output = [ 'ca1amity', 'cod3', 'di5aster', 'ca11ing', 'ho2me3' ]; Therefore, let's write the code for this problem − Understanding the Problem Each string contains embedded numbers. We need to extract these numbers and sort the array ... Read More
To check if a string begins with punctuation in JavaScript, we can use regular expressions to test the first character against common punctuation marks. The Problem Consider these example strings where we need to detect if they start with punctuation: var sentence1 = 'My Name is John Smith.'; var sentence2 = '? My Name is John Smith.'; console.log("Testing strings:"); console.log("1:", sentence1); console.log("2:", sentence2); Testing strings: 1: My Name is John Smith. 2: ? My Name is John Smith. Using Regular Expression with match() We can create a regular expression ... Read More
In JavaScript, when a function is called without arguments or with undefined values, you can set default parameter values to prevent errors and provide fallback behavior. Basic Default Parameter Syntax The simplest way to set default values is using the ES6 default parameter syntax: function functionName(parameter = defaultValue) { // function body } Example: Simple Default Parameters function greet(name = 'Guest') { console.log(`Hello, ${name}!`); } greet(); // No argument passed greet('Alice'); ... Read More
We are required to write a JavaScript recursive function that takes in a number and returns the greatest digit in the number. For example: If the number is − 45654356 Then the return value should be 6 How It Works The recursive approach extracts digits one by one from right to left using modulo (%) and integer division. Each digit is compared with the current maximum, and the function calls itself with the remaining digits. Example Following is the code − const num = 45654356; const greatestDigit = (num ... Read More
In this tutorial, we will learn how to find the value of a button with JavaScript. Button elements often have a value attribute that stores important data for form processing or identification purposes. JavaScript provides the value property to access this attribute programmatically. Understanding how to retrieve button values is essential when working with HTML forms and interactive web applications. Button value Property The button value property returns the value of the value attribute assigned to a button element. This property is commonly used to distinguish between multiple buttons or pass specific data when forms are submitted. ... Read More
To create a new img tag with jQuery using data from a JavaScript object, you can pass an HTML string to the jQuery constructor or use the attribute object syntax. Method 1: Using HTML String and attr() Create an img element and set attributes using the attr() method: // JavaScript object with image data var imageData = { id: 'dynamic-image', src: 'https://via.placeholder.com/150', alt: 'Dynamic Image' }; // Create img element and set attributes var myImg = $(''); myImg.attr('id', imageData.id); myImg.attr('src', imageData.src); myImg.attr('alt', ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Economics & Finance