avatarTim Han

Summarize

Basics of JavaScript: Data Types

Welcome back everyone to my second blog on basics of JavaScript. I want to continue our talk on some of the fundamentals in JavaScript.

In the last blog, I talked about what a variable is, how to declare a variable, and how to assign a variable a value. If you didn’t get a chance to check that out the make sure you read it here. Alternatively, you can watch the video on YouTube here.

In this blog, I want to take the time to go over the different data types that exist in JavaScript according to EcmaScript standards.

What is a data type?

Data type in programming is a category of data that is often represented in a specific way to be distinguished between each other.

What are the data types available in JavaScript?

  • Number
  • String
  • Boolean
  • Undefined
  • Null
  • Symbol (As of EcmaScript 2015)
  • Object

These data types also have two categories: Primitive vs. Non-Primitive

What is a primitive data type and which ones?

Primitive data types are immutable meaning not able to be changed and these are the primitive types in JavaScript:

  • Number
  • String
  • Boolean
  • Undefined
  • Null
  • Symbol

How about non-primitive types?

Non-primitive type is just opposite of a primitive type meaning it can be changed and there’s only one non-primitive type:

  • Object

Now, let’s go over each data type in JavaScript!

Number

  • Unlike some other programming languages, JavaScript only has one type of a number.
  • There are 3 different common symbolic values for numbers in JavaScript, +Infinity, -Infinity, NaN (Not a number)

Examples: 1, 2.2, -5, 100

String

  • String in JavaScript represents some textual data
  • Values of type string are enclosed in quotation marks
  • Often times, you will see either single quotation or double quotation marks

Examples: “Hello World”, ‘I love coding!’, “What is life.”

Boolean

  • Represents a logical entity that can have one of two values true or false

Examples: true, false

Undefined

  • Undefined value is assigned to newly created variable that isn’t assigned with any value

Null

  • There is only one possible value for null which is null
  • Null represents a reference to a non-existent entity or some invalid address in memory

Symbol

  • In JavaScript, there is a Symbol() function available which is used to create a value of type symbol
  • Each symbol return from the function is unique

Object

  • Objects are often represented with curly braces
  • Object represents an instance that one can access its members
  • There is one very special type of an object called an array

Those are all the data types available in JavaScript at a quick glance. As we take a deeper journey into JavaScript, we will encounter many instances of these data types.

There is also a YouTube video available for those of you who would prefer a visual/audio for learning from this link here.

In the meantime, feel free to leave any questions, comments, or feedback in the comment section below.

Be sure to tune in for the next blog/video on basic arithmetic operators available in JavaScript.

For new contents:

Subscribe on YouTube here!

Follow on Twitter here!

See you guys next time!

Programming
JavaScript
Technology
Software Development
Software
Recommended from ReadMedium