0

I came across the following statement in a Redux demo:

const { createStore } = Redux

I don't really understand the syntax nor where it comes from ... ES6? Also how is it different from an import statement.

Manuel RODRIGUEZ
  • 1,781
  • 3
  • 18
  • 45
  • This is called destructuring. – SLaks Aug 24 '17 at 19:03
  • 1
    https://stackoverflow.com/questions/35415978/syntax-const-variablename-can-anyone-explain-or-point-me-into-the-right-d?noredirect=1&lq=1 – adeneo Aug 24 '17 at 19:04
  • The way you could've found it out yourself would be googling for *ecmascript 6 curly braces*. Not that hard, I think. – Al.G. Aug 24 '17 at 19:04
  • @Al.G. disagree it's not actually that easy to find if you don't already know what it's called... nor which version of JavaScript it was introduced in. It was closed as a duplicate and rightly so, but I think it's a perfectly reasonable question for a beginner to *ask*. As a further example, try to find info on arrow functions without using the word arrow or ES 6/2015 (i.e. you don't already know what the name is). There are at least two answered questions about it on SO but I'll be impressed if you find them. – Jared Smith Aug 24 '17 at 19:06
  • @JaredSmith Obviously the question was tagged as ecmascript 6 so the OP knew which version it was related to. I myself have also never heard of "*destructing & aliasing*" in JS before and as I found, "curly braces" is enough for google to tell you what that is. – Al.G. Aug 24 '17 at 19:10
  • @Al.G. fair enough it is the number one google hit for 'ES 6 curly braces'. – Jared Smith Aug 24 '17 at 19:11
  • @JaredSmith about the second one... plese: https://www.google.com/search?q=javascript+-%3E+() The first result tells it is called "arrow functions" – Al.G. Aug 24 '17 at 19:12
  • @Al.G. google search has gotten smarter then. I went to close [this question](https://stackoverflow.com/questions/33376028/what-does-it-mean-equal-and-greater-than-sign-in-javascript/) as a dupe but when searching for it via 'javascript =>' I got nothing useful so I answered it. Turned out it actually *was* a dupe, but neither the OP or I found it. Now that search gets you the MDN docs as the #1 hit. The quest for world domination rolls onward I see. – Jared Smith Aug 24 '17 at 19:19
  • @AI.G. I am not an English native speaker. I tried to search Google with my "own words" such as : "Javascript const vs import" etc. but I haven't find what seemed to be an obvious and clear answer to my interrogation. I actually indeed didn't had the reflex to search the exact term "curly braces", my mistake... I am sorry if it disturbed you that much... Thanks everyone for the help. – Manuel RODRIGUEZ Aug 24 '17 at 20:33

0 Answers0