<!-- Please press ctrl-shift-i to see output in browser console window. -->
JavaScript
var company = {
name: 'Microsoft',
location: 'Gurgaon'
};
//Old way to access object and its property values before ES6
console.log(`One of ${company.name}'s campuses is located in ${company.location}`);
var companyInfo = {
companyName: "Microsoft",
companyLocation: 'Gurgaon'
};
//new way to access object and its property values using ES6
var {companyName, companyLocation} = companyInfo;
console.log(`One of ${companyName}'s campuses is located in ${companyLocation}`);
//Important Note: property names inside object (line no.10 & 11) must be same as the variables names (line no. 14).
//If we want to assign a property to a variable with another name, for example : i want to assign companyInfo.companyName to a variable named 'cn', then
var {companyName: cn, companyLocation: cl} = companyInfo;
console.log(`One of ${cn}'s campuses is located in ${cl}`);
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.