✂️ Frontend Snips

Implicit return object

26/07/2018 — 1 Min Read — In JavaScript, ES6

ES5

const make = 'Ford';
const model = 'Mustang';
const engine = '5.0';

const car = {
  make: make,
  model: model,
  engine: engine,
};

ES6

const make = 'Ford';
const model = 'Mustang';
const engine = '5.0';

const car = {
  make,
  model,
  engine,
};
PreviousObject Literal console logs
NextTotal up the instances of items in an array.
© 2019 by Ash Hitchcock. All rights reserved.
View on GitHub
Last updated: 2022-09-05