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-Class.js
class Person {
constructor(name = '', age = 0) {
this.name = name;
this.age = age;
}
getName() {
return this.name;
}
}
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-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-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-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-restParam.js
// rest param example
var multipleInputs = function (value, ...restParamValues ) {
restParamValues.forEach( function(paramVal){
// do something with paramVal
});
}
View es6-spread.js
var state1 = {
val1 : 'abc',
val2: 'xyz'
};
var state2 = {
val2 : 'mno',
val3: 'xyz'
};
View es6-letConst.js
var value1 = 100;
let value2 = 100;
{
var value1 = 200
let value2 = 200
}
console.log(value1); // 200
console.log(value2); // 100
View es6-promise.js
var myPromise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve(10);
}, 1000);
});
// handler can't change promise, just value
myPromise.then((result) => {
console.log(result);
}).catch((err) => {
View Tries:Contacts.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class TriesContacts {
static class Node {
HashMap<Character, Node> links = null;
boolean isFinish;
You can’t perform that action at this time.