Orbit Reached
You have completed all mission contexts.
Falsiness
Only a few specific things are secretly 'False': 0, empty strings (''), null, undefined, and NaN. Everything else in the JS universe is True.
Truthiness
In JS, every value has a hidden Boolean identity. Numbers, full strings, and objects are secretly considered 'True' if asked to act like a light switch.
Escaping Characters
If you want to put a quote mark inside a quote ('It's hot'), the computer thinks the string ended early. Use a backslash ('It\'s hot') to tell the computer to ignore it.
Template Literals
Instead of gluing strings with '+', use backticks (`). You can inject variables directly into the text like this: `Welcome to ${planet}`. It is much cleaner.
Copying Objects (References)
If you copy an Object, JS doesn't clone it. It just gives you two remote controls pointing to the exact same TV. Changing one affects the other.
Copying Primitives
If you copy a primitive (let a = b), JS creates a brand new, independent clone. Changing 'a' will never affect 'b'.
Memory: The Heap
Objects and Arrays can grow huge, so the computer tosses them into a massive warehouse called the 'Heap'. It's slower to find things, but holds endless data.
Memory: The Stack
Primitives are small, so the computer stores them in a fast, organized filing drawer called the 'Stack'. It's quick to access but has limited space.
Arrays (Lists)
An Array is a special type of Object. It's just a numbered list. let planets = ['Earth', 'Mars', 'Jupiter']. It holds multiple items in a specific order.
Creating an Object
We build objects with curly braces {}. let car = { color: 'red', speed: 100 }. We just stored two separate pieces of data inside one 'car' variable.
Objects: The Complex Type
Primitives hold one thing. Objects hold many things. Think of an Object like a file cabinet. It's one piece of furniture, but it has many labeled folders inside.
typeof NaN is Number?
Weirdly, if you ask typeof(NaN), JS says it's a Number. It's essentially a special number category meant to represent a broken calculation.
NaN (Not a Number)
If you try to do math with words, like 10 / 'Apple', the computer returns NaN. It literally means 'Not a Number'βit's the computer's way of saying the math failed.
Type Conversion
You can manually force data to change types. Number('10') forces the text '10' to become a real mathematical number you can use in equations.
Type Coercion
If you try to add a Number and a String (5 + ' Apples'), JS panics, assumes you want a String, and forces the number to become text, resulting in '5 Apples'.
Adding Numbers vs Strings
If you do 5 + 5, you get 10. But if you do '5' + '5' (in quotes), JS glues the text together, giving you '55'. Quotes completely change the math!
String Concatenation
If you add two strings together ('Hello ' + 'World'), the computer glues them together into one long text block: 'Hello World'.
Dynamic Typing
Unlike some languages, JS boxes don't care what you put in them. A box can hold a Number today, and you can swap it for a String tomorrow without the computer yelling at you.
The 'typeof' Operator
If you don't know what is inside a box, ask the computer! Typing typeof(5) will return 'number'. Typing typeof('hello') returns 'string'.
Primitive: BigInt
Regular JS numbers have a size limit. If you are calculating something massive (like stars in the universe), you use BigInt to allow for infinitely large numbers.
Primitive: Symbol
A Symbol is a unique identifier. Even if two Symbols have the same description, they are mathematically guaranteed to be completely unique from each other.
Undefined vs Null
Undefined is an empty box you forgot to pack. Null is an empty box you specifically labeled 'KEEP EMPTY'. Both represent nothing, but for different reasons.
Primitive: Null
Null is similar to undefined, but it is intentional. It means you purposefully put 'nothing' inside the box. It represents an intentional blank space.
Primitive: Undefined
If you create a box (variable) but forget to put anything inside it, the computer labels its contents as 'undefined'. It means 'I exist, but I'm empty right now.'
Primitive: Booleans
A Boolean only has two possible forms: true or false. Think of it as a light switch. It is either completely ON or completely OFF.
Single vs Double Quotes
You can use 'single' or "double" quotes for strings. JS doesn't care, as long as you match the start and end. If you start with a single, end with a single.
Primitive: Strings
Strings are text. They must always be wrapped in quotation marks, like 'Hello' or 'John123'. Without quotes, JS gets confused and thinks it's a variable.
Primitive: Numbers
Numbers are just math numbers. 5, -10, or 3.14. You don't use quotes around them. You can add, subtract, and multiply them directly.
Two Main Categories
Data in JS falls into two buckets: Primitive (simple, single things) and Objects (complex collections of things).
What are Data Types?
If you are packing a suitcase, you pack liquids in bottles and clothes in bags. Programming is the same. We have different 'types' of data, and we handle them differently.
Lecture 02: Data Types in Javascript
Total Duration: 2 hrs 4 mins 12 secs