I have been using JS policy a lot in case i need to satisfy a use case that can’t be done via policies. I had restricted myself to using “var” when it comes to declaring or instantiating variables. Recently, I found that we can use ES6 coding standards in JS policy and I started using “let” and “const” key words and ran into the following problems:
- “let” cannot can be used in a JS policy. Compiler throws an error if you try to use this keyword. (Being a big fan of “let” & “const”, this was a huge disappointment)
- const doesn’t scope variables within the blocks (if-else…). I used a variable with “const” in “if” block and then used the same variable name with “const” in else block. Output: “cannot redeclare variable” (this was another shocker)
Please help me to understand, what exactly is happening here? @Dino-at-Google
