Krantik Chavan

Krantik Chavan

176 Articles Published

Articles by Krantik Chavan

Page 3 of 18

How do you check that a number is NaN in JavaScript?

Krantik Chavan
Krantik Chavan
Updated on 15-Mar-2026 350 Views

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 More

Fire a JavaScript function when a user finishes typing instead of on key up?

Krantik Chavan
Krantik Chavan
Updated on 15-Mar-2026 380 Views

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 More

What is an alert box in JavaScript?

Krantik Chavan
Krantik Chavan
Updated on 15-Mar-2026 1K+ Views

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 More

What is if...else if... statement in JavaScript?

Krantik Chavan
Krantik Chavan
Updated on 15-Mar-2026 483 Views

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 More

How to determine if an argument is sent to the JavaScript function?

Krantik Chavan
Krantik Chavan
Updated on 15-Mar-2026 161 Views

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 More

What is the difference between a++ and ++a in JavaScript?

Krantik Chavan
Krantik Chavan
Updated on 15-Mar-2026 8K+ Views

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 More

How to use variable number of arguments to function in JavaScript?

Krantik Chavan
Krantik Chavan
Updated on 15-Mar-2026 716 Views

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 More

Usage of CSS align-content property flex-start value

Krantik Chavan
Krantik Chavan
Updated on 15-Mar-2026 198 Views

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 More

Set the style of the rule between columns with CSS

Krantik Chavan
Krantik Chavan
Updated on 15-Mar-2026 204 Views

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 More

Change the size of the pagination with CSS

Krantik Chavan
Krantik Chavan
Updated on 15-Mar-2026 437 Views

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
Showing 21–30 of 176 articles
« Prev 1 2 3 4 5 18 Next »
Advertisements