Beginner Codes/JavaScript/Data Types
20%

Instructions

Data Types 🏷️

JavaScript has several built-in data types to represent different kinds of information.

Primitive Types

TypeExampleDescription
string"Hello"Text
number42, 3.14Numbers (both integer and decimal)
booleantrue, falseLogical values
undefinedundefinedNo value assigned
nullnullIntentionally empty

typeof Operator

Use typeof to check a value's type:

console.log(typeof "Hello");   // "string"
console.log(typeof 42);        // "number"
console.log(typeof true);      // "boolean"

💡 Did You Know? Unlike many languages, JavaScript uses a single number type for both integers and decimals.

Your Turn!

Print the typeof the number 2024.

Help

Data TypesExercise 3/1015 XP
❴❵ script.js
javascript.code
javascript
Loading...
Terminal
Terminal — javascript
Beginner Codes Terminal v1.0.0
─────────────────────────────────────
Ready. Click "Run Code" to execute...
Ready
Piston APIJAVASCRIPT0 lines