ES6 in Depth
  • Introduction
  • Installation
  • Block Scope
    • Constant
    • Use cases
  • Template String
    • New String Methods
    • Tagged Template Literal
  • New Number Methods
  • Arrow Function
    • Default Parameters
    • Lexical This Scope
    • Where not to use arrow function
  • Object Enhancement
  • New Array Methods
    • For Of
  • Spread Operator
  • Destructuring
    • Array Destructuring
  • Class
  • Symbols
  • New Data Structures
    • Set
    • Map
    • WeakSet
    • WeakMap
    • Iterators
    • Generators
  • Promise
  • Import Export
Powered by GitBook
On this page

Was this helpful?

Arrow Function

// ES5
function greet(name){
    console.log("Hello! "+ name);
}
greet("Hemant");

// ES6
var greet = (name) => console.log("Hello! "+ name);
greet("Hemant");

// for single method parameter we can ommit () see below
// OR ( as returned value)
var greet = name => "Hello! "+ name;
console.log(greet("Hemant"));

Implicit return {}

const winners = ['Rob', "Dome", "Hemant"];

const win = winners.map(w => ({name: w})); // use ()

console.log(win);
PreviousNew Number MethodsNextDefault Parameters

Last updated 4 years ago

Was this helpful?