Start here.
A value is one piece of data: 12, 'hello', and true are three examples. A type is the kind of value. Numbers describe quantities, strings describe text, and booleans have exactly two values, true and false. Quotation marks tell JavaScript that characters are text: 12 is a number but '12' is a string. They may look similar on a screen, yet adding, comparing, and storing them can behave differently.
A variable is a name that lets later code refer to a value. let makes a binding that can be assigned a different value later. const makes a binding that cannot be reassigned. JavaScript does not require the name to keep one type: let item = 42; followed by item = 'forty-two'; makes item refer to a string. The type belongs to the value, not to the spelling of the name. Reassignment replaces what the name refers to; it does not edit the number 42.
The other primitive kinds are bigint for very large whole numbers, symbol for unique keys, undefined for a missing value, and null for intentional emptiness. Objects hold collections of properties; arrays and functions are also objects in this broad sense. A property is a named part of an object, such as user.name. You do not need to memorize every kind at once. First learn to ask: what value is here, what kind is it, and what operation am I asking JavaScript to perform?
Build the model.
Numbers, strings, booleans, bigints, symbols, undefined, and null are primitive values. Objects, including arrays and functions, carry identity. JavaScript is dynamically typed: a binding can later point at a value of another type, although clear code rarely changes its meaning casually.
The type of a value determines which operations make sense. A string can be sliced, a number can be multiplied, and an object can have properties. Learn the value before judging an expression. Remember that typeof null returning 'object' is a historical quirk, not a useful model of null.
How it works.
A value is the actual piece of data an expression produces. A binding is a name that lets you reach a value again. JavaScript asks the value, not the binding, which operations are meaningful. A number can participate in arithmetic; a string can be concatenated or sliced. Because types are attached to values, the same let binding can refer to a number now and a string later.
Use typeof as a first clue, then check the behavior you actually need. typeof [] says 'object' because arrays belong to the object family; Array.isArray tells you whether the value is specifically an array. null is an intentional empty primitive even though typeof null historically reports 'object'. Also remember that NaN still has type number: it represents a failed numeric computation, not a new type.
Read it line by line.
let item = 42;
item = 'forty-two';
console.log(typeof item); // 'string'First notice. The binding stayed; the value it refers to changed.
The declaration gives item the number value 42. The next assignment replaces the value reached through item with a string; it does not transform 42 itself. When typeof reads item, it sees the current string and yields 'string'. If you had used const, the reassignment would be rejected because the binding was promised a stable reference.
See the rule again.
const values = [1, 2];
console.log(typeof values);
console.log(Array.isArray(values));The output is 'object' and true. An array is an object, so typeof gives the broad category. Array.isArray asks the more precise question. Choose a check that matches the behavior your next line relies on.
One thing to remember.
Bindings hold values. Values have types.