values

A screen lit up with object where I expected null That little incident taught typeof better than any tutorial

const label = "0x1RIS";
const port = 443;
let enabled = true;

console.log(`${label}:${port}`);

The primitives

string , number , boolean , undefined , null , symbol , bigint Everything else is an object of some kind

typeof null

Output:

object

JavaScript history, not a bug you can fix Check value === null directly when it matters

let and const

let counter = 0;
counter = 1;

const fixed = 443;

const stops reassignment of the binding It does not freeze the object inside it That distinction has burned more people than reassignment ever did

When to use each

  • const by default
  • let when the value genuinely changes
  • var almost never , its scope is the function rather than the block

Next

Strings and operators in 02 strings

Posted