🌐
GeeksforGeeks
geeksforgeeks.org › javascript › variables-datatypes-javascript
Variables and Datatypes in JavaScript - GeeksforGeeks
The const keyword declares variables that cannot be reassigned. It's block-scoped as well. ... JavaScript supports various datatypes, which can be broadly categorized into primitive and non-primitive types. Primitive datatypes represent single values and are immutable. 1. Number: Represents numeric values (integers and decimals). ... Non-primitive types are objects and can store collections of data or more complex entities.
Published   February 24, 2018
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Grammar_and_types
Grammar and types - JavaScript | MDN
The latest ECMAScript standard defines eight data types: ... Boolean. true and false. null. A special keyword denoting a null value. (Because JavaScript is case-sensitive, null is not the same as Null, NULL, or any other variant.) undefined. A top-level property whose value is not defined. Number. An integer or floating point number. For example: 42 or 3.14159. BigInt. An integer with arbitrary precision. For example: 9007199254740992n. String. A sequence of characters that represent a text value.
🌐
W3Schools
w3schools.com › js › js_variables.asp
JavaScript Variables
Creating a variable in JavaScript is called declaring a variable. You declare a JavaScript variable with the let keyword or the const keyword. ... After the declaration, the variable has no value (technically it is undefined). To assign a value to the variable, use the equal sign: ... The two variables price1 and price2 are declared with the const keyword. The values of price1 and price2 cannot be changed.
🌐
Turing
frontend.turing.edu › lessons › module-1 › js-intro-to-data-types-variables.html
JS: Data Types & Variables - Front-End Engineering Curriculum - Turing School of Software and Design
JavaScript recognizes a few different types of variables: var, let, and const. They each behave a little differently, so it’s important to understand the differences. If you don’t, you might run into some errors. In your first module, you’ll mostly see var.
🌐
Learn JavaScript
learn-js.org › en › Variables_and_Types
Variables and Types - Learn JavaScript - Free Interactive JavaScript Tutorial
There are two more advanced types in JavaScript. An array, and an object. We will get to them in more advanced tutorials. const myArray = []; // an array const myObject = {}; // an object · On top of that, there are two special types called undefined and null. When a variable is used without first defining a value for it, it is equal to undefined. For example:
🌐
TutorialsPoint
tutorialspoint.com › javascript › javascript_variables.htm
JavaScript - Variables
Here, we have given a full list of the JavaScript revered keywords. You can use the $ and _ to define the variables in JavaScript, as the JavaScript engine considers it a valid character. In this example, we have defined the variables using the var keyword. The first variable name starts with the underscore, and the second variable name starts with the dollar sign.
🌐
W3Schools
w3schools.com › js › js_datatypes.asp
JavaScript Data Types
In the second example, since the first operand is a string, all operands are treated as strings. JavaScript has dynamic types. This means that the same variable can be used to hold different data types: let x; // Now x is undefined x = 5; // Now x is a Number x = "John"; // Now x is a String Try it Yourself » · A string (or a text string) is a series of characters like "John Doe". Strings are written with ...
🌐
Career Karma
careerkarma.com › blog › javascript › javascript variables
JavaScript Variables: The Complete Guide | Career Karma
December 1, 2023 - We also discussed the three main types of variables in JavaScript — var, let, and const — and explored how they can be used. Finally, we discussed the role of scope, redeclaring variables, and hoisting in JavaScript variables.
🌐
Techotopia
techotopia.com › index.php › JavaScript_Variable_Types
JavaScript Variable Types - Techotopia
JavaScript supports five different types of variable. These variable types are outlined in the following table together with examples and a brief description of each type:
Find elsewhere
🌐
Medium
medium.com › @kaklotarrahul79 › understanding-javascript-variables-and-primitive-data-types-step-by-step-1cdf3bb46b48
Understanding JavaScript Variables and Primitive Data Types Step by Step | by Rahul Kaklotar | Medium
January 18, 2025 - Declare variables using var, let, and const. Try updating their values and observe the behavior. Create examples for each primitive data type and use typeof to check their types. Create an object and an array, then modify their properties or ...
🌐
MindMajix
mindmajix.com › blog › javascript › types of javascript variables
▷ Types of JavaScript Variables | What is JavaScript
There are three types of keywords for a variable declaration in JS: var, let, and const. ... Var - It is an outdated keyword in Javascript. We cannot declare a variable without var in older browsers.
🌐
TutorialsTeacher
tutorialsteacher.com › javascript › javascript-variable
JavaScript Variables (With Examples)
In JavaScript, a variable can be declared using var, let, const keywords. Learn all about JavaScript variables in detail.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-use-variables-and-data-types-in-javascript
How to Use Variables and Data Types in JavaScript – Explained With Code Examples
August 19, 2024 - For example, pneumonoultramicroscopicsilicovolcanoconiosis is a valid variable name in JavaScript even though it is long. It is generally a good practice to give meaningful names to variables and they should be of a reasonable length. Let your variables be simple and contextual. For example: author, publishedDate, readTime, shouldCompress, and so on. It should be self-explanatory. Just avoid cryptic names where possible. Even though we can create variables as we wish, some names are already being used within JavaScript to mean something specific.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Scripting › Variables
Storing the information you need — Variables - Learn web development | MDN
To do this, we type the keyword let followed by the name you want to call your variable: ... Here we're creating two variables called myName and myAge. Try typing these lines into your web browser's console. After that, try creating a variable (or two) with your own name choices. Note: In JavaScript, all code instructions should end with a semicolon (;) — your code may work correctly for single lines, but probably won't when you are writing multiple lines of code together.
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › javascript fundamentals
Data types
For example, a variable can at one moment be a string and then store a number: // no error let message = "hello"; message = 123456; Programming languages that allow such things, such as JavaScript, are called “dynamically typed”, meaning that there exist data types, but variables are not bound to any of them. ... The number type represents both integer and floating point numbers.
🌐
Scientech Easy
scientecheasy.com › home › blog › types of variables in javascript
Types of Variables in JavaScript - Scientech Easy
August 4, 2025 - Learn types of variables in javascript with example program, scope of variables in javascript, global scope, local scope, no block scope
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-variables
JavaScript Variables - GeeksforGeeks
Variables in JavaScript can be declared using var, let, or const. JavaScript is dynamically typed, so variable types are determined at runtime without explicit type definitions.
Published   September 27, 2025
🌐
Programiz
programiz.com › javascript › data-types
JavaScript Data Types (with Examples)
In JavaScript, null represents "no value" or "nothing." For example, ... Here, let number = null; indicates that the number variable is set to have no value. Visit JavaScript null and undefined to learn more. A Symbol is a unique and primitive value. This data type was introduced in ES6.
Top answer
1 of 11
23

JavaScript variables are not typed.

JavaScript values are, though. The same variable can change (be assigned a new value), for example, from uninitialized to number to boolean to string (not that you'd want to do this!):

var x;       // undefined
x = 0;       // number
x = true;    // boolean
x = "hello"; // string
2 of 11
9

Javascript is dynamically typed, whereas other languages, C# and Java for example, are statically typed. This means that in Javascript variables can be reassigned to values of any type, and thus that you don't ever need to explicitly denote the type of variables or the return type of functions. If you saw code like this in a statically typed language

int x = 5;
x = "hello";

you would rightfully expect the compiler to start throwing up a big nasty TypeError. Javascript, on the other hand, will happily run this code even though the type changed.

var x = 5;
x = "hello";

Because variables can change types, the compiler can't know as much information about them. You should expect the tools for Javascript to be inferior to those of Java/C# as far as useful niceties like code completion go. Fewer mistakes will be caught at compile time and you will have to do more runtime debugging than you are probably used to.

That said, this also allows you to be more free with your variables and you can change types at will, which can often be convenient. You can write code like this if you want:

var x;               //typeof x === "undefined"
x = "Hello, world!"; //typeof x === "string"
x = 42;              //typeof x === "number"
x = false;           //typeof x === "boolean"
x = {};              //typeof x === "object"