javaScript?.Fundamentals
Tags: javascript, beginners, tutorial
Published: 2022-08-15 16:43:00

Here’s a few things to know when getting started with Javascript

## Variables

Variables are used to store data, like the price of a item

 `let` and `const` are used to declare variables

Variables declared with `const` can not be updated later in your code, variables declared with `let` can be updated throughout your code.
Use `const` to store data you don’t expect to change, like your first name

## Console Log

`console.log` is used to view data in the terminal. `console.log` will be your best friend when you run into bugs. You will have the ability to log variables into the terminal to see where the error is coming from 	

## What type of data can be stored in a variable?

JavaScript has 7 primitive data types & 1 non primitive data type

**String** 

- A sequence of text wrapped around double quotes: "", single quotes: '', or backticks: ``

![string](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/68nchpg26rud59o56ynz.jpeg)

_If you’re storing a string with double quotes within, use single quotes or backticks_

You can also add other variables into a string using string interpolation. To use string interpolation you must 

- wrap your string in backticks
- add a dollar sign
- add curly braces
- write your variable inside of the curly braces 

![String Interpolation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/83gpjcjq8xeyxy3h5l37.jpeg)

**Number**
- A number is just a number, numbers do not need to be wrapped in quotes like a string.
- Decimal numbers are called `floats`

![number](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/exi3p4d5u990si6rh3qp.png)

**Boolean** 

- True or False.

![boolean](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r38ibtrycf4ti88p3wvh.jpeg)

**`undefined`**

- Variables declared with no value will be `undefined`.
- Variables declared with `undefined` will have a value of undefined

![undefined](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3cy55a4jire6ablqwfmm.jpeg)

**`null`**  

- An empty or a unknown value

- Unlike the undefined keyword we are defining a variable with a value of nothing.

![null](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mfb0xhm28jxnes73xfhc.jpeg)

**[Bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)**
-  A number too larger to be stored in javascript's number data types

**[Symbol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol)**
- A value that is unique and unchangeable


## Non primitive data types / Collections of data

**Object**
- Objects are written with curly brackets and hold {`key` : `value`} pairs.. 

- An object's `key` is known as the property (the title of the `value` its attached to)

- `value` can `=` any javascript data type | primitives and non primitives

- We can use Dot Notation to access a objects property and we will get the `value` in return - ex: `object.property`


![objects](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uoqfy8sv70qt4qajz57u.jpeg)

**Array**
- Arrays are "list-like" objects that store multiple data types into a collection
- Arrays are written with brackets `[]` and hold multiple data types that are separated by commas `[1,"a",true,null]`
- Data in a array can be accessed individually by its index (numbered position in a list, javascript counts from 0) using bracket notation - ex: `array[0]`

![arrays](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xuogalfe9ewk6c63p0pi.jpeg)

## Operators

- Operators are symbols used to preform operations on values and variables.

**Assignment Operator**: 

- Used to assign values to variables  `=` 

**Arithmetic Operators**

- Used to preform arithmetic calculations

![arithmeticOperators](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eryvfnijm1zz96njjpyg.png)


![arithmeticOperators](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ejhl902bjq36yre91t9h.png)


Using `+=` or any arithmetic, assignment operator combination pair will update our initial variables value `+=` `-=` `*=` `/=` `%=`

![arithmeticOperatorsTerminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ph4az2td3nvct4bzby8i.png)

**Comparison operators**
- Used in logical statements to determine equality of values or variables, returns a true or false boolean value

![comparisonOperators](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ub7a2ay9r88jg5cqnxep.png)
- The equal to operator (==) will convert strings into numbers and compare values regardless of data type
- The strictly equal to operator(===) will only return true if both values are equal and have equal date types
- The not equal to operator(!=) will n
![comparisonOperators](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zh725z9wa9zkdgaj7i5w.png)

![comparisonOperatorsTerminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2htrwxbv49yxmw0yyndg.png)

**Logical Operators**
- Used to determine the true or false logic between variables and values
`(&&) , (||), (!)`


![logicalOperators](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0jm8f1kkp689dx4omoaz.png)

- both values on each side of the and operator must be true for us to get a return value of true
![addOperator](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rhh3v9eocqnt61b4fgk6.png)
![orOperator](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m5tpo567xixnvhfnwvlq.png)
![bangOperator](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m7sa2tc4mg8l2tvbongj.png)



**String Operators**
 - Add strings together. We can combine two strings into one using the `+` operator or the `+=` operator


**JAVASCRIPT FUNDAMENTALS PART 2... COMING SOON**