DEV Community

Cover image for JavaScript values are data
Michel Reyes
Michel Reyes

Posted on

2

JavaScript values are data

This is one of the most important things if you arrive at JS world: there are only two (2) main types of values:
Alt Text

For both primitives and objects there are sub-types, let's expand our vision a little more:
Alt Text
There is no specific reason in the order for JS, I just order it that way because is the way I use to remember all of them: BUSN (boolean, bigint, undefined, string, symbol, null, number)

What about objects?

Well, we can say that everything else is an object or derive from an object.
Alt Text

Functions like arrays are a special kind of object (sub-types).

Datatypes

You can check the type of a value using the typeof operator.
Alt Text

There are two "wild" data types that can be confused:
functions and null
Alt Text

As I mention before functions are special kind of object. In this particular case function is a shorthand response; at the end of the day, the Function constructor is derived from Object constructor.

The case of the null, well this is a little tricky one... I'm going to let that homework for you.

Conclusion

  • There are 2 main value types in JS: primitives and objects.
  • There are 9 sub-types: (BUSN) boolean, bigint, undefined, string, symbols, numbers, null, objects and functions.

The latest ECMAScript standard defines nine types.

That's All Folks, hope you learn and enjoy it.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay