what is the difference between const and const {} in javascript
问题 When I study electron, I found 2 ways of getting BrowserWindow object. const {BrowserWindow} = require('electron') and const electron = require('electron') const BrowserWindow = electron.BrowserWindow What is the difference between const and const {} in JavaScript? I can't understand why the const {} can work. Do I miss anything important about JS? 回答1: The two pieces of code are equivalent but the first one is using the ES6 destructuring assignment to be shorter. Here is a quick example of