How to do it...

  1. Open your command-line application and navigate to your workspace.
  2. Create a new folder named 06-09-create-objects-with-structuring.
  3. Copy or create an index.html that loads and runs a main function from main.js.
  4. Create a main.js file with an async function named main, which creates several constants and then uses object structuring to create an object with properties of the corresponding names and values:
// main.jsexport function main() { 
  const prop1 = 'some value'; 
  const prop2 = 'some other value'; 
  const objectProp = { foo: 'bar' }; 
  const object = { prop1, prop2, objectProp }; 
 
  console.log(object); 
} 
  1. Start your Python web server and open the following link in your browser: http://localhost:8000/.
  1. You should see the following ...

Get ECMAScript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.