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.

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs