Lesson 3 of 16
Lesson Progress: 0%
Code Example
let name = "Alice";
console.log(name);
let age = 25;
console.log(age);Instructions
▲ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
"Alice" and 25, are called primitive data types.Code Example
let isOnline = true;
console.log(isOnline));
let emptyValue = null;
console.log(emptyValue);Instructions
▲ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
true, numbers, or null are called primitive data types.Code Example
let x = 10;
let y = x;
y = 20;
console.log(x); // 10
console.log(y); // 20Instructions
▲ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
10 and 20 are primitive data types in JavaScript.y is set equal to x, it gets its own copy of the number.y does not change x because primitive values do not share the same memory.Code Example
let colors = ["red", "green", "blue"];
console.log(colors);
let person = { name: "John", age: 30 };
console.log(person);
let student = {
name: "Sam",
grades: [90, 85],
active: true
};
console.log(student);Instructions
▲ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
Code Example
let today = new Date();Instructions
▲ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
new Date(), it is too large to fit inside a normal variable box.today variable that points exactly to where the calendar is hiding!Code Example
let a = { value: 10 };
let b = a;
b.value = 20;
console.log(a.value); // 20
console.log(b.value); // 20Instructions
▲ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
a in this example is a reference data type because it stores grouped information.b is set equal to a, it does not make a copy, but points to the same place in memory.b.value also changes a.value, since they share the same object.b is set equal to a, it does not make a new copy.b, you might accidentally change a too.