List of helpful shortcuts for faster coding
If you have any other helpful shortcuts, feel free to add in the comments of this gist :)
function multiply(num1, num2) { | |
return num1 * num2; | |
} |
function multiply(num1, num2) { | |
return num1 * num2; | |
} |
const multiply = (num1, num2) => { | |
return num1 * num2; | |
} |
// Single line arrow function | |
const multiply = (num1, num2) => num1 * num2; |
const myFunction = () => ({ value: 'test' }) | |
myFunction() | |
// returns: { value: 'test' } |
// without parentheses - single arguement | |
const doubleNumber = num => num * 2; |
// In ES5 | |
var obj = { | |
id: 1, | |
printId: function printId() { | |
setTimeout(function() { | |
console.log(this.id); | |
}.bind(this), 1000) | |
} | |
} | |
// In ES5, bind(this) is required to pass the context of the function |
var name = 'World'; | |
var message = 'Hello ' + name; | |
console.log(message); | |
// prints: Hello World |
const name = 'World'; | |
const message = `Hello ${name}`; | |
console.log(message); | |
// prints: Hello World |