5

In Javascript 1.7 the let keyword introduces block scope. This is arguably the most needed feature of Javascript and I was wondering if Node.js supports it.

Part of my difficult in ascertaining this is Node runs Google's V8 engine, which comes from such and such standard and I don't know how these line up with the Javascript x.y version numbers.

djechlin
  • 59,258
  • 35
  • 162
  • 290
  • 4
    Wouldn't this be **trivial** to test yourself, and in less time than it took to write the question? – Matt Ball Mar 07 '13 at 23:39
  • @MattBall I would find out what version of node I happen to be using at the moment - not if it's possible to depend on libraries that are using a different version then blow up, not if there's reasons it's yes but grossly unsafe, etc. – djechlin Mar 07 '13 at 23:41
  • @MattBall so yes, the answer below is something I would not have found by trying myself. – djechlin Mar 07 '13 at 23:42
  • 1
    This page is currently top of Google for "node.js let keyword", so it might be an idea to lose some of the negativity, particularly with regard to it being a duplicate. – Fergie Jun 12 '15 at 17:40

1 Answers1

12

Yes, the let keyword is supported, provided you run Node with the --harmony flag. However, I wouldn't recommend using let in production software. (by the way, you could have found this answer via search, before you asked a new question)

Community
  • 1
  • 1
Elliot Bonneville
  • 51,872
  • 23
  • 96
  • 123
  • 1
    I'm guessing it's poor practice to use in a production application since I can't assume a user of my library is run? And I actually didn't find that somehow but am happy to close my own question as dupe. – djechlin Mar 07 '13 at 23:43
  • 1
    Yes, and because it's not exactly standard functionality yet. – Elliot Bonneville Mar 07 '13 at 23:45
  • what is the scene now. Is Let good to be used in production. – indolentdeveloper Dec 04 '15 at 13:38
  • We are using it in a controlled production environment with babel without issue. However if it is not a standard yet so you may want to take that into consideration when deciding to use it or not in a production application. – Ryan Rentfro Jul 19 '16 at 20:24