Exploring JavaScript Data Types and Variable Declarations📦📊🖥

Exploring JavaScript Data Types and Variable Declarations📦📊🖥

“You should imagine variables as tentacles, rather than boxes. They do not contain values; they grasp them—two variables can refer to the same value.”-Marijn Haverbeke

What is a Variable?

A variable can be defined as a container for storing data item values. Javascript variables can be declared using: var, let or const.

Javascript is case-sensitive, so when declaring variables you must be cautious. i.e. var Name ≠ var name .

JS Datatypes

Below are some of the datatypes in Javascript :

- Strings: a series of characters enclosed in single or double quotes.

-Numbers: numbers can be either be integers(whole numbers) or floating points (decimal numbers).

-Booleans: this datatype can only have two values, true or false.

-Arrays: this is an object that contains multiple values at once. Arrays are enclosed in square brackets [ ].

-Objects: This is a datatype that contains properties with values, separated by commas, enclosed in curly brackets { }.

The typeof operator

The typeof operator is used to find the data type of a Javascript variable.

typeof "Gracetoffy"// returns string 
typeof 278 // returns number
var book = {
 title:"Harry Potter",
 author: "J.K Rowling", 
 rating:4.9 , 
 no_of_series: 7
typeof book // returns object
var a = 24;
var c = 24;
var equal = a==c
typeof equal // returns boolean 

var books =[ "Harry Potter", "Beautiful Creature",
 "A Midsummer’s dream", "39 clues"]
typeof books //returns object

Thanks for reading :) !!