YouTip LogoYouTip

JavaScript Variables and Data Types

Data Types

let str = "Hello";       // string
let num = 42;            // number
let bool = true;         // boolean
let arr = [1, 2, 3];     // array
let obj = {key: "val"};  // object
let nothing = null;      // null
let undef;               // undefined

Template Literals

let name = "Alice";
console.log(`Hello, ${name}!`);

Destructuring

let {name, age} = person;
let [first, second] = [1, 2];

Summary

  • 7 primitive types + object
  • Template literals use backticks
  • Destructuring extracts values easily
← JavaScript Functions and ScopeJavaScript Tutorial - First St β†’