Array and data types

Post created on: 11/12/2019

This weekend while attempting to do some learning without really having a plan (which as it turns out funnily enough is a dumb idea) I messed around with Sass and webpack for a bit before heading back to Mozilla Developer Network to look up some vanilla JavaScript stuff as the amount I appear to have forgotten in the past few months is more than I thought and I need to go over some things again.

Firstly I looked up arrays so what is an array you ask according to MDN:

An array is an ordered collection of data (either primitive or object depending upon the language). They are used to store multiple values in a single variable. This is compared to a variable that can store only one value.

I knew can hold many different types of data what I learnt was the difference between types of data.

Primitive data is not an object and has no methods.

There are 7 primitive data types in JavaScript:

  • String - anything in quotes (single or double)
  • Boolean - true or false
  • Number - integers or floating numbers e.g. 3.14
  • Null - there is no value or it is empty
  • Undefined - a value is not defined
  • BigInt - which admittedly I'd never heard of until I looked it up :eyes:
  • Symbol - a new value introduced in ES6/ES2015

In JavaScript arrays are zero indexed and have many methods associated with them. Some of which I will go into in a future post once I've refreshed on the more common ones.