Javascript Function Arrow function with rest parameter

Description

Javascript Function Arrow function with rest parameter

'use strict';/*  w  ww  .java  2  s. c o m*/

var x = (a, b, ...rest) => [a, b, rest];
console.log(x(1, 2, 3, 4));  // [ 1, 2, [3, 4] ]

// Specs: Arguments should not exists
// Babel: Arguments exists
var y = (a, b, ...rest) => arguments;
console.log(y(1, 2, 3, 4));

Return object literal

'use strict';/*from w w  w .  ja  v a  2 s.c om*/

// Need ()
var a = x => ({value: x});

console.log(a(123));  // { value: 123 }



PreviousNext

Related