Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
39
rated 0 times [  40] [ 1]  / answers: 1 / hits: 27674  / 12 Years ago, sun, july 1, 2012, 12:00:00

Does node.js support a let statement something like what's described on MDN??



var x = 8,
y = 12;

let ( x = 5, y = 10) {
return x + y;
} //15


If not, is there a way to duplicate the functionality with a self-executing anonymous function or something?



And/or is there another js environment that




  1. has let and and

  2. has a REPL, as node does? Rhino?



EDIT:



This question was asked quite a while ago. As of now, late 2015, the answer is Yes, yes it does. Harmony features were included by default in io.js 3.3, and have been recently brought back to node.js with the 4.x release.


More From » node.js

 Answers
46

I don’t think Node supports let, but you can do this:



var a = 5;

(function () {
var a = 6;
console.log(a); // => 6
})();

console.log(a); // => 5

[#84543] Friday, June 29, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kamronr

Total Points: 749
Total Questions: 110
Total Answers: 122

Location: Dominica
Member since Sat, Nov 5, 2022
2 Years ago
kamronr questions
Mon, Dec 21, 20, 00:00, 3 Years ago
Fri, Oct 16, 20, 00:00, 4 Years ago
Sat, Oct 3, 20, 00:00, 4 Years ago
Sun, Jul 28, 19, 00:00, 5 Years ago
;