I use let for the in for loop keyword gives SyntaxError: Unexpected identifier

I am using let for the in for loop keyword as shown below.

for(let methd1 in servUrl){ let methd=methd1; for(let pth1 in servUrl[methd]) { let pth=pth1; app[methd](pth, servUrl[methd][pth]); } } 

which gives me the following error

 for(let methd1 in servUrl){ ^^^^^^ SyntaxError: Unexpected identifier 
+5
source share
3 answers

Can you make sure that if you are using a supported version of node.

To find out the version of node, you can run the following command:

 $ node --version v4.2.1 

Node older versions do not support let or EcmaScript6 all functions.

I also ran into a similar problem and updated my node to solve my problem.

To update node, you can follow these steps:

 $ sudo npm cache clean -f $ sudo npm install -gn $ sudo n stable 
+7
source

You may also need to simulate your node binary with updated binary. This worked for me:

 sudo ln -sf /usr/local/n/versions/node/5.0.0/bin/node /usr/bin/node 
+2
source

I used the let keyword in the entther scope, but I get the same syntax error message.

The problem was that I was using an old version of Chrome (38) and I am upgrading to version 54 and now it works. The "let" key was not recognized by the old version.

+1
source

Source: https://habr.com/ru/post/1234240/


All Articles