Skip to content

Instantly share code, notes, and snippets.

rohit chopra rohit012

Block or report user

Report or block rohit012

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View es6-destructuring.js
var bodyObj = {
height: 16,
width: 9,
breadth: 20;
};
//without destructuring
var height = bodyObj.height;
var width = bodyObj.width;
var breadth = bodyObj.breadth;
View es6-defaultParams.js
// without default params
var myFunc = function (value, options){
var value = value || 0;
var options = options || {};
// do some stuff
}
// with default params
var myFunWithDefaultParam = function (value = 0, options = {}){
// do some stuff
View es6-templateStrings.js
const person1 = 'Bob';
const person2 = 'Fred';
//using typical string concatenation
let oldConcatStr = 'We know that ' + person1 + ' is friends with ' + person2;
//using template strings
let newConcatStr = `We know that ${person} is friends with ${person2}`
View es6-arrow-functions.js
var multiplyAndPrint = (num1, num2) => {
let result = num1*num2;
return result;
}
// no brackets or return is required if function has just one line
var square = num => return num*num;
View es6-Class.js
class Person {
constructor(name = '', age = 0) {
this.name = name;
this.age = age;
}
getName() {
return this.name;
}
}
You can’t perform that action at this time.