[JavaScript Demo] Object Destructuring with rest operator in ES6

This example demonstrates how to destructre JavaScript object with rest parameter using ES6.

by Rahul Saraswat

HTML

<!-- Please press ctrl-shift-i to see output in browser console window. -->

JavaScript

var companyInfo = {
	name: 'Microsoft',
  location: 'USA',
  ceo: 'Sundar Pichai'
};

var {name, ...rem} = companyInfo;
//remaning properties are part of rest parameter now and can be accessed using rem.
console.log(`Current CEO of ${name} is ${rem.ceo}, located in ${rem.location}`);