Type
ELI5 — The Vibe Check
A type tells the computer what kind of thing a value is — is it a number, text, true/false, or a list? Types matter because you cannot add a number to a word (well, JavaScript will try anyway). Types help the computer know what operations make sense on a value.
Real Talk
A type (or data type) is a classification that specifies what kind of value a variable holds and what operations can be performed on it. Primitive types (number, string, boolean, null, undefined) hold simple values directly. Reference types (object, array, function) hold a pointer to a memory location. Languages enforce types either at compile time (static typing) or at runtime (dynamic typing).
Show Me The Code
// JavaScript types (dynamic — determined at runtime):
typeof 42; // 'number'
typeof 'hello'; // 'string'
typeof true; // 'boolean'
typeof null; // 'object' (famous JS bug!)
typeof undefined; // 'undefined'
typeof {}; // 'object'
typeof []; // 'object' (arrays are objects in JS)
typeof function(){}; // 'function'
// TypeScript types (static — checked at compile time):
const age: number = 25;
const name: string = 'Alice';
const active: boolean = true;
When You'll Hear This
"What type does that function return?" / "Type errors at compile time are way better than at runtime."
Related Terms
Boolean
A boolean is the simplest value in programming — it is either true or false. On or off. Yes or no. 1 or 0. Named after mathematician George Boole.
Float
A float is a number with a decimal point — 3.14, 1.5, -0.001. The name comes from 'floating point' because the decimal point can be anywhere.
Integer
An integer is a whole number — no decimal point. 1, 42, -7, 1000 are integers. 1.5 is NOT an integer, that is a float.
Static Typing
Static typing means you have to tell the computer what type each variable is when you write the code, and it checks everything is correct BEFORE running.
String
A string is text in programming — any sequence of characters wrapped in quotes. 'Hello', 'user@email.com', '12345' — if it is in quotes, it is a string.
TypeScript
TypeScript is JavaScript with a strict parent watching over it.