DEV Community

stalin s
stalin s

Posted on

JavaScript Primitive types

**Primitives Types **in JavaScript.

These are Seven basic data types in JavaScript.

listed below.
1) String.
2) Number.
3) Boolean
4) Null
5) Undefined
6) Symbol
7) BigInt.

Let's explore these javaScript primitives.


A String represents text data in JavaScript. You create strings by enclosing them in quotation marks:

'Have a nice day'

Image description

We can use singular quote marks ('') or double quote marks ("") to create a string.

Number :

A Number represents numeric data. In Javascript, we can create numbers by writing the number directly in its numeric form:


Image description

Boolean :

Booleans are very much like light switches. They can only be “switched on” (true) or “switched off” (false).

console.log(true) // true
console.log(false) // false

Image description

Happy Learning

Top comments (0)

11 Tips That Make You a Better Typescript Programmer


1 Think in {Set}

Type is an everyday concept to programmers, but it’s surprisingly difficult to define it succinctly. I find it helpful to use Set as a conceptual model instead.

#2 Understand declared type and narrowed type

One extremely powerful typescript feature is automatic type narrowing based on control flow. This means a variable has two types associated with it at any specific point of code location: a declaration type and a narrowed type.

#3 Use discriminated union instead of optional fields


Read the whole post now!