0

Reference: http://electron.atom.io/docs/tutorial/quick-start/

const electron = require('electron');
const {app} = electron;

What is the difference between const var_name and const {var_name}? When should I use const var_name or const {var_name}?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
q0987
  • 34,938
  • 69
  • 242
  • 387
  • 2
    This is called _Destructuring assignment_ you can read more about it at MDN https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment – antyrat May 19 '16 at 15:25

1 Answers1

2

The following makes the variable "electron" reference what is returned from the require function:

const electron = require("electron")

The following is called a Destructuring assignment and makes the variable "app" reference whatever the property "app" of electron is referencing:

const {app} = electron;

It is the equivalent of writing:

const app = electron.app;
metarmask
  • 1,747
  • 1
  • 16
  • 20