JavaScript ternary operator | Multiple, nested and shortHand codes

JavaScript ternary operator is frequently used as a shortcut for the if statement. It’s a one-line shorthand for an if-else statement and also called the conditional operator in JavaScript. The ternary operator is the only JavaScript operator that takes three operands. First condition followed by a question mark (?), then an expression to execute if Read More…


Single line if statement JavaScript | Best One Line syntax

One way is to use a ternary operator which works as a single line if statement in JavaScript. This is the best way, let’s see the example code:- The ? : is called a ternary operator and acts just like an if/else when used in an expression Examples of the single line if statement JavaScript Read More…


JavaScript number format comma | HTML format number thousands separator

How to JavaScript number format comma? OR HTML format number thousands separator It’s an very easy to do it: There is a built in function for this, You can use The toLocaleString() method to return a string with a language-sensitive representation of a number Or Regular Expressions. Complete example of convert format number into thousands Read More…


JavaScript validate float number | HTML code example

You can validate the float number in JavaScript using regular expression (Regex). And another way is doing division by 1 with condition statements. How do I check that a number is a float or integer? check for a remainder when dividing by 1: See below complete example code to test number need two functions. Output: Read More…


Validate decimal numbers in JavaScript | Match, and RegEx

Use match() method to Validate decimal numbers in JavaScript. Here is example code to validate decimal numbers. Output: Regex in JavaScript for validating decimal numbers Use the following expression as below example code. Output: Do comment if you have any questions and suggestions on this topic. RohitDegree in Computer Science and Engineer: App Developer and Read More…



js onload Event | Run function on-page is loaded JavaScript

With the JS onload event, you can Execute JavaScript immediately after a page has been loaded. It works when on when an object has been loaded. onload is most often used within the element to execute a script once a web page is fully loaded. Syntax HTML JavaScript Examples of JS onload Event Let’s see Read More…


JavaScript clearTimeout Method | Clear timeout Example code

JavaScript clearTimeout Method is used to clears the timeout which has been set by setTimeout() function before that. The setTimeout() method is return ID, which has to use in the clearTimeout() method as a parameter. Syntax clearTimeout(id_of_settimeout) Parameter Values Only ID value needed which returned by the setTimeout() method Example of JavaScript clearTimeout() Method Let’s see the Read More…


JavaScript clearInterval method | clears the interval example code

JavaScript clearInterval method is used to clears the interval which has been set by setInterval() function before that. A setInterval() method is return id which will used as the parameter for the clearInterval() method. Syntax clearInterval(var) Parameter Values The id of the timer returned by the setInterval() method Example of Javascript clearInterval() Method setInterval() method execute the “myTimer” function Read More…


JavaScript setInterval Method | stop, loop examples

JavaScript setInterval method evaluates an expression at specified intervals (in milliseconds). You need to clearInterval() method to stop the setInterval() method. Note: 1000 ms = 1 second. If you want to execute a function only once Then use the setTimeout() method. Syntax Parameter Values function:- The function that will be executed milliseconds:- The intervals (in milliseconds) on Read More…