CodeOrbit

🏁

Orbit Reached

You have completed all mission contexts.

Context 30 / 30

Falsiness

Only a few specific things are secretly 'False': 0, empty strings (''), null, undefined, and NaN. Everything else in the JS universe is True.

Context 29 / 30

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.

Context 28 / 30

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.

Context 27 / 30

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.

Context 26 / 30

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.

Context 25 / 30

Copying Primitives

If you copy a primitive (let a = b), JS creates a brand new, independent clone. Changing 'a' will never affect 'b'.

Context 24 / 30

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.

Context 23 / 30

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.

Context 22 / 30

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.

Context 21 / 30

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.

Context 20 / 30

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.

Context 19 / 30

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.

Context 18 / 30

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.

Context 17 / 30

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.

Context 16 / 30

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'.

Context 15 / 30

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!

Context 14 / 30

String Concatenation

If you add two strings together ('Hello ' + 'World'), the computer glues them together into one long text block: 'Hello World'.

Context 13 / 30

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.

Context 12 / 30

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'.

Context 11 / 30

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.

Context 10 / 30

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.

Context 9 / 30

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.

Context 8 / 30

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.

Context 7 / 30

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.'

Context 6 / 30

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.

Context 5 / 30

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.

Context 4 / 30

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.

Context 3 / 30

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.

Context 2 / 30

Two Main Categories

Data in JS falls into two buckets: Primitive (simple, single things) and Objects (complex collections of things).

Context 1 / 30

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.

← Abort Mission

Lecture 02: Data Types in Javascript

Total Duration: 2 hrs 4 mins 12 secs

Initiate Launch Scroll UP to ignite thrusters