0Pricing
Frontend Academy · Lesson

Data Types: string number boolean null undefined

Explore JavaScript's primitive types, use typeof to inspect them, and learn the difference between null and undefined.

JavaScript's Type System

JavaScript is dynamically typed — variables don't have types, values do. The same variable can hold a string, then a number, then null. Understanding the seven primitive types prevents a huge class of bugs.

string

Strings represent text. Use single quotes, double quotes, or backtick (template literal). They are immutable — string methods return new strings. Strings have a .length property and many built-in methods.

const greeting = 'Hello';
const lang = "JavaScript";
const sentence = `I love ${lang}`;  // template literal

console.log(greeting.length);   // 5
console.log('hello'.toUpperCase()); // 'HELLO'
console.log(' trim me '.trim()); // 'trim me'

All lessons in this course

  1. Variables: let const var and Scope
  2. Data Types: string number boolean null undefined
  3. Functions: declarations expressions arrow functions
  4. Control Flow: if else switch for while
← Back to Frontend Academy