xFactorSchool.com
Python
JavaScript
How to Do Examples
C Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Compilers
C Compiler
C++ Compiler
C# Compiler
Java Compiler
Python Compiler
HTML Code Editor
CSS Code Editor
JavaScript Compiler
JavaScript Code Editor
Practice how to declare data type variable in JavaScript
JavaScript Online Editor
Run Code
More JavaScript Sample Codes
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Declare JavaScript Data Type Variables</title> <!--Script tag is added to write JavaScript code inside it--> <script> // number data type for integer and floating point number var integerNumber = 55; var floatNumber = 55.55; // string data type used for text var stringVar = "JavaScript is a great fun."; // Boolean data type var boolVar = true; // Object var person = {firstName:"John", lastName:"Smith"}; function myFunction() { document.getElementById("myNumber").innerHTML = integerNumber + " and " + floatNumber + " are number data type."; document.getElementById("myString").innerHTML = stringVar; document.getElementById("myBool").innerHTML = boolVar + " is a boolean data type."; document.getElementById("myObject").innerHTML = person.firstName + " is the firstName value of person object."; } </script> </head> <body> <h1>How to declare javascript data type varibable?</h1> <button onclick="myFunction()">Click here to see result</button> <p id="myNumber"></p> <p id="myString"></p> <p id="myBool"></p> <p id="myObject"></p> </body> </html>