Data Type
In one line
A data type tells the computer what kind of value a variable holds — text, number, true/false, and so on.
In simple words
A data type is a category that describes what a value is and what you can do with it. Common types include strings (text), numbers (integers and decimals), booleans (true/false), and more complex types like arrays and objects.
Types matter because the computer treats each kind of value differently. You can add two numbers together (5 + 3 = 8), but adding two strings concatenates them ("5" + "3" = "53"). Knowing the type tells the computer which operations are valid.
Some languages (like Python, JavaScript) figure out the type automatically from the value you assign. Other languages (like Java, C) require you to declare the type explicitly. Either way, understanding data types is essential to writing correct programs.
Example
let name = "Ada"; // string
let age = 25; // number
let isReady = true; // boolean
console.log(typeof name); // "string"
console.log(typeof age); // "number"
console.log(typeof isReady); // "boolean"typeof reveals the data type of each variable: string, number, and boolean.
Common confusions
Confused with: string vs integer
The difference: A string is text enclosed in quotes ("25"); an integer is a whole number (25). "25" + "25" gives "2525", but 25 + 25 gives 50.
Related terms
Related Resources
Related Lessons
- Data Types
Deep dive into each data type
Related Practice
Learn the fundamentals
Deepen your understanding with structured lessons on this topic.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.