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 Krantik Chavan
Page 3 of 18
How do you check that a number is NaN in JavaScript?
NaN is a JavaScript property representing "Not-a-Number" value. It indicates that a value is not a legal number. JavaScript provides two methods to check for NaN values: Number.isNaN() and the global isNaN() function. Syntax Number.NaN Number.isNaN(value) isNaN(value) Using Number.isNaN() (Recommended) Number.isNaN() is the most reliable method as it only returns true for actual NaN values without type coercion: Check with Number.isNaN() function display() { ...
Read MoreFire a JavaScript function when a user finishes typing instead of on key up?
To fire a JavaScript function when the user finishes typing instead of on every keystroke, use a debouncing technique with setTimeout and clearTimeout. This prevents the function from executing until the user stops typing for a specified delay. The Problem Using keyup or input events directly fires a function on every keystroke, which can cause performance issues or unwanted API calls. Debouncing ensures the function only runs after the user has finished typing. Example with jQuery ...
Read MoreWhat is an alert box in JavaScript?
An alert dialog box is mostly used to give a warning message to the users. For example, if one input field requires to enter some text but the user does not provide any input, then as a part of validation, you can use an alert box to give a warning message. Nonetheless, an alert box can still be used for friendlier messages. Alert box gives only one button "OK" to select and proceed. Syntax alert(message); Parameters: message - The text to display in the alert dialog box Example ...
Read MoreWhat is if...else if... statement in JavaScript?
The if...else if... statement allows JavaScript to evaluate multiple conditions sequentially and execute the first matching condition's code block. Syntax The syntax of an if...else if statement is as follows: if (condition1) { // Code to execute if condition1 is true } else if (condition2) { // Code to execute if condition2 is true } else if (condition3) { // Code to execute if condition3 is true } else { // Code to execute if no condition is true } How It ...
Read MoreHow to determine if an argument is sent to the JavaScript function?
To determine if an argument is sent to a JavaScript function, you can use several approaches including default parameters, checking for undefined, or using the arguments object. Using Default Parameters Default parameters provide fallback values when arguments are not passed or are undefined: function display(arg1 = 'Tutorials', arg2 = 'Learning') { document.write(arg1 + ' ' + arg2 + ""); } ...
Read MoreWhat is the difference between a++ and ++a in JavaScript?
In JavaScript, ++a (pre-increment) and a++ (post-increment) both increase a variable by 1, but they differ in when the increment happens and what value they return. Pre-increment (++a) ++a increments the variable first, then returns the new value. The ++ operator comes before the operand. Post-increment (a++) a++ returns the current value first, then increments the variable. The ++ operator comes after the operand. Example: Basic Difference let a ...
Read MoreHow to use variable number of arguments to function in JavaScript?
In JavaScript, functions can accept a variable number of arguments using the arguments object or modern rest parameters (...args). The arguments object contains all arguments passed to a function, regardless of how many parameters are defined. Using the arguments Object The arguments object is an array-like object that contains all arguments passed to a function: function functionArgument(val1, val2, val3) { var res = ...
Read MoreUsage of CSS align-content property flex-start value
The CSS align-content property with the flex-start value aligns flex lines to the beginning (top) of the flex container. This property only works when there are multiple lines of flex items, which requires flex-wrap: wrap to be set. Syntax selector { align-content: flex-start; } Example The following example demonstrates how align-content: flex-start positions flex lines at the top of the container − .mycontainer { display: flex; ...
Read MoreSet the style of the rule between columns with CSS
The CSS column-rule-style property is used to set the style of the rule (line) between columns in a multi-column layout. This property works in conjunction with column-count or column-width to create visual separators between columns. Syntax selector { column-rule-style: value; } Possible Values ValueDescription noneNo rule between columns (default) solidA solid line between columns dashedA dashed line between columns dottedA dotted line between columns doubleA double line between columns ridgeA 3D ridged border grooveA 3D grooved border Example: Dashed Column Rule The following example creates a ...
Read MoreChange the size of the pagination with CSS
To change the pagination size in CSS, you can use the font-size property to make pagination elements larger or smaller. This affects both the text size and the overall visual impact of your pagination buttons. Syntax .pagination a { font-size: value; } Example: Large Pagination Buttons The following example creates pagination with increased size using font-size: 18px − .demo { display: inline-block; } .demo ...
Read More