๐ง๐๐ฝ๐ฒ๐ฆ๐ฐ๐ฟ๐ถ๐ฝ๐ ๐ฃ๐ฟ๐ถ๐บ๐ถ๐๐ถ๐๐ฒ ๐ง๐๐ฝ๐ฒ๐ ๐๐๐ถ๐ฑ๐ฒ
TypeScript has 7 primitive types. They are the simplest building blocks of your code. Each type holds one value.
You use these three most often:
- string: text like names or IDs.
- number: all numbers, including decimals.
- boolean: true or false.
The other four serve specific needs:
- null: an intentional empty value.
- undefined: a value not set yet.
- bigint: huge whole numbers.
- symbol: a unique ID.
Follow these rules for better code:
- Use lowercase names. Write string, not String.
- Let TypeScript guess the type. This is called inference.
- Write the type only when it is not clear.
This keeps your code safe and clean.