JS Scrimba
JS Scrimba
// HINTS:
// localStorage.setItem(key, value)
// localStorage.getItem(key)
// localStorage.clear()
// PS: both key and value need to be strings
JSON.Parse()=>string to array
JSON.stringify()=>object,array to string
Refactoring JavaScript Refactoring means updating the source code without changing
the behaviour of the application
String literals=>it uses back ticks(` `) and access the value of the variable using string
interpolation(${var1..})
Example:let text = `Welcome ${firstName}, ${lastName}!`;
Destructuring Object:unpack the values from the array and store it in the distinct variable
Example:
const obj = { a: 1, b: 2 };
const { a, b } = obj;
// is equivalent to:
// const a = obj.a;
// const b = obj.b;
Destructuring Array
Example:let [num1,num2,num3] = [1,2,3]
//num1=1
//num2=2
//num3=3
Rest Operator=> return rest of the specified value in a array which is declared in parameter
Example:
Function fn(...nums){
return nums
}
o/p=[1,2,3,4,5,6]
fn(1,2,3,4,5,6)
Functions
NORMAL FUNCTION
function fun(){
return “hii”
}
fun()//calling
ANONYMOUS FUNCTION
const f = function(){
return “hiii”
}
f()..calling
ARROW FUNCTION
const f = () => “hii”
f()//calling
Default Exports
JS CALLBACK
A function is passed as a argument for another function
SYNCHRONOUS
Code will be executed from top to bottom
ASYNCHRONOUS
It starts with long running task that is performed along with other task in parallel manner
eg:settimeout()
JS PROMISE
Its a special object that represents whether the operation is success or failed(resolve,reject)
JS FETCH
It fetch the data from the server.req(api)=>res(json)
API
Application Programming interface it act as an intermediate between client request and server
response it give response based upon the specified request.