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

Build Your Own Forms without Manual Coding

SurveyJS UI libraries let you build a JSON-based form management system that integrates with any backend, giving you full control over your data with no user limits. Includes support for custom question types, skip logic, an integrated CSS editor, PDF export, real-time analytics, and more.

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