Links:
### Variables in Javascript:
1. let - Modern Js (Prevents defining the variable twice)
2. var - Allows overriding of identifiers
3. const - constant variable
### Datatypes in Javascript:
1. Numbers
2. Objects
3. Booleans
4. String
5. undefined
6. null
### Functions in Javascript:
1. **Functions**: Allows to run specific set of code once when the function is hit.
```
function hello(){
console.log ("Hey Abhishek");
}
```
2. **Objects**: Like a dictionary, allows to access values while storing them as objects.
```
let obja = {
r:34,
m:64
}
```
3. **Functions in Objects**: Concatenation example:
```
let obja = {
r: 34,
m: 64,
func: function myfunc(number) {
console.log("The number is" + number);
}
```
### Events in Javascript:
Hovering a mouse over the nav bar (element) is like an even, there can be multiple events in JS which we can listen to. This is something which is how event listening works in Mixpanel I suppose where in these events are added and then those are used to track a user behaviour in the application.
```
document.addEventListener("click", function click() {
console.log ("clicked");
//alert ("hello")
let conf = confirm("Are you sure?");
console.log(conf);
}
```
### Strings in JS and their Methods
### Callbacks in Javascript:
Callbacks prevents blocking of functions in javascript so that things keep on going smoothly.
Callbacks are such functions which invokes when a task has already been completed. eg. setTimeout
```
mobj.myfunc();
console.log(mobj.a);
setTimeout(() = > {
console.log ("yayyy")
}, 3000);
console.log("I am the bottom string")
```
### Promises in Javascript
- I am about to do something, and as soon as that thing finishes, I will run the function.
- Promises are either resolved or rejected.