JavaScript Refresher

let and const

console.log(test);//undefined
var test = "Hi";
var test = "Hi"
var no = 5
if (no == 5) {
var test = 0;
}
console.log(test);//0

Arrow functions

function myDobuleFun(no){
return no * 2;
}
const myDoubleFun = (no) => {
return no * 2;
}
const myDobuleFun = no => no * 2;

Exports and Imports(Modules)

//test.js
const test = 10;
export default-test;
//app.js
import test from './test.js'
import t from './test.js'
//util.js
export const pi = 3.14;
export const e = 2.718;
//app.js
import {pi} from './util.js'
import {e} from './util.js'
import {pi as math_pi} from './util.js'
import * as bundled from './util.js'

Spread and Rest Operators

let no = [1, 2, 3];
let newNo = [...no, 4];//[1, 2, 3, 4]
let newNo = [no, 4];//[[1, 2, 3], 4]
const filter = (...args) => {
return args.filter(e1 => e1 === 1);
}

Destructuring

[a, b] = ['Hi', 'World'];
console.log(a); //Hi
console.log(b); //World
{name} = {name: 'John', age: 20};
console.log(name)//John
console.log(age)//undefined

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store