# Ultimate JavaScript basics before any library

The ultimate JavaScript basics you must know before shifting to a library/framework.
 
- Variables
- Objects
- Functions
- Arrays
- Conditions
- DOM

## Variables in JavaScript
Variables are used to store data. There are three types of variables:

```
const name = 'Priyanshu'
let age = 22
var lovesJavaScript = true 
```

var - Global scope and can be redefined.

let (ES6) - Local scope and can be redefined.

const  (ES6) - Local scope and cannot be redefined.

Here is a  [video explanation](https://youtu.be/tWHTUTE58BU).

## Objects in JavaScript
They say JavaScript is all about objects.
Objects are just variables containing many values.

```
let person = {
   name: “Priyanshu",
   username: “priyanshu769”
 }

person.name 
// Outputs Priyanshu

person.username 
// Outputs priyanshu769

```

Access this: `person.name` gives us ‘Priyanshu’ string and similarly, `person.username` would 'priyanshu769'.

## Functions in JavaScript
Functions are blocks containing a set of instructions that will be executed when the function is called. The block must start with a keyword `function`. But this was changed after ES6 came into play.

```
// Functions before ES6
function square (num) {
   return num * num
}

// Functions after ES6
const square = (num) => {
   return num * num
}
// Both callbacks would return the same value
```

Here is a detailed  [video explanation](https://youtu.be/vtRCpg1S2yE) for functions.

## Arrays in JavaScript
Arrays contain a set of data with an `index number`. The `index number` can be used to access the data but accessing data through the index is not that useful.
Detailed  [video explanation](https://youtu.be/Bl1W9j7GnNU) of Objects & Array

## Conditions in JS
Conditions are something that you understand in plain English.
There are `if else` statements where it is defined that if such condition is satisfied, execute `a block` else execute `b block`.
Detailed  [video explanation](https://youtu.be/KFvfwiP4s08) for conditions.

## JavaScript DOM
DOM stands for Document Object Model. Didn't help. It’s not JavaScript DOM, it’s JavaScript HTML DOM. An interface or a structure of a web application so that it can be used by the program to change the structure, style, or the content itself of the application.
 
## Conclusion
If it was helpful, It would be great that you share this article with people who can benefit from this.

I also tweet stuff related to development. You can check it  [here](https://twitter.com/Priyanshu769).

Like this post for better reach and appreciation. Comment your thoughts, waiting for them eagerly.

Chao till the next one.

*Priyanshu*
