How to declare numbers in JavaScript?

JavascriptWeb DevelopmentFront End Technology

JavaScript is untyped language. This means that a JavaScript variable can hold a value of any data type. To declare variables in JavaScript, you need to use the var keyword. Whether it is a number or string, use the var keyword for declaration.

Here’s how you can declare numbers in JavaScript −

var points = 100;
var rank = 5;


You can try to run the following code to learn how to declare number in JavaScript −

            var age = 20;
            if( age > 18 ){
               document.write("<b>Qualifies for driving</b>");

Updated on 13-Jun-2020 07:43:55