What is a Value in JavaScript?

Learn what is considered a value in JavaScript.

In JavaScript, the term value is an abstract (broad) concept because many things are considered values and there are many types of values. For example:

  • numbers
  • strings
  • functions
  • objects
  • boolean
  • null
  • undefined

If you’re ever in doubt about the type of a value in JavaScript, put typeof in front of the value. Try the examples below in your console:

console.log(typeof "Hi there!")
// output: "string"

console.log(typeof 7)
// output: "number"

console.log(typeof function toggleNav() {} )
// output: "function"

console.log(typeof {} )
// output: "object"

console.log(typeof true)
// output: "boolean"

console.log(typeof dog)
// output: "undefined"

These values are the most common ones you’ll see in the wild when starting out learning JavaScript. There is more to say about values and value types than this, but I want to keep this post simple and beginner-friendly.

I firmly believe that gradually increasing your tech-vocabulary is a better way to learn than bombarding yourself with countless of terms at once.


Has this been helpful to you?

You can support my work by sharing this article with others, or perhaps buy me a cup of coffee 😊

Kofi

Share & Discuss on