DEV Community

Cover image for What are the different data types present in JavaScript?
Dhairya Shah
Dhairya Shah

Posted on • Originally published at codewithsnowbit.hashnode.dev

3 2

What are the different data types present in JavaScript?

banner

To know the type of the value/variable, we can use the typeof operator

Primitive Types

  • String

A string is represented by the series of characters enclosed by double/single quotes

const name = "SnowBit"
const favLang = "JavaScript"
Enter fullscreen mode Exit fullscreen mode
  • Integer

It represents a number that can be written with or without a decimal

const age = 18
const price = 24.02
Enter fullscreen mode Exit fullscreen mode
  • Boolean

It is a logical entity that has only two values: true and false, basically, booleans are used for conditional operations

const access = true
const isAdmin = false
Enter fullscreen mode Exit fullscreen mode
  • Undefined

When a variable is declared but not assigned, the value of that variable is undefined

  • Null

It represents invalid or non-existent value

const api = null
Enter fullscreen mode Exit fullscreen mode

Thank you for reading, have a nice day!

Cover Photo by Richard Horvath on Unsplash

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay