🌐
W3Schools
w3schools.com › js › js_datatypes.asp
JavaScript Data Types
This means that the same variable ... JavScript object or a User defined object. ... You can use the JavaScript typeof operator to find the type of a JavaScript variable....
🌐
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.
🌐
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   November 19, 2025
🌐
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.
🌐
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.
🌐
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.
🌐
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.
🌐
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:
🌐
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
🌐
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.
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"
🌐
DEV Community
dev.to › clifftech123 › javascript-from-beginner-to-master-tutorial-series-37fe
Part (1): Variables and Data Types in JavaScript - DEV Community
June 4, 2023 - Null represents nothing, while undefined represents an uninitialized variable. Symbols are unique and immutable data types, and objectsare collections of key-value pairs. Arrays are ordered collections of values. JavaScript has several built-in data types, including: In JavaScript, all data types except for Objects and Arrays are primitive data types. In JavaScript, strings are used to store text and are surrounded by quotes. There are three types of quotes you can use: ... // String Examples const singleQuotes = "Hello, this is a single quote in JavaScript"; const doubleQuotes = "Hello, this is a double quote in JavaScript"; const name = "Clifford"; const backticks = `Hello, ${name}. This is a backtick in JavaScript`;
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Data_structures
JavaScript data types and data structures - JavaScript | MDN
All primitive types, except null and undefined, have their corresponding object wrapper types, which provide useful methods for working with the primitive values. For example, the Number object provides methods like toExponential(). When a property is accessed on a primitive value, JavaScript automatically wraps the value into the corresponding wrapper object and accesses the property on the object instead. However, accessing a property on null or undefined throws a TypeError exception, which necessitates the introduction of the optional chaining operator.
🌐
DEV Community
dev.to › joanayebola › variables-and-data-types-in-javascript-for-beginners-338o
Variables and Data Types in JavaScript for Beginners - DEV Community
September 26, 2023 - They are versatile and can store various data types: ... Objects are the cornerstone of JavaScript and are employed for organizing and managing complex data structures. You can access and manipulate the data within objects using their keys. Arrays are ordered collections indexed by numbers. They are used to store multiple values in a single variable:
🌐
TutorialsPoint
tutorialspoint.com › home › javascript › javascript variables
JavaScript Variables - Learn How to Use Them Effectively
September 1, 2008 - 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.
🌐
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
🌐
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.
🌐
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 ...
🌐
Marius Schulz
mariusschulz.com › blog › variables-and-types-in-javascript
Variables and Types in JavaScript — Marius Schulz
December 22, 2020 - Values of different types can be ... 1337 of type number · The above code is perfectly valid because in JavaScript, variables don't have types....