2

So, I noticed that on CodePen invalid property accessors that should give Syntax Error is working.

I have a res object:

let res = {
  "a" : {
    "b" : 123
  },
  "c" : 3
}

When I do:

console.log("Valid: ",  res["a"]["b"])
console.log("Invalid: ",  res.["a"].["b"])

I get a response on the console:

"Valid: " 123

"Invalid: " 123

As far as I know res.["a"].["b"] is invalid JavaScript Syntax and it doesn't work elsewhere. Is there any reason why it's implemented this way or am I missing something?

Here's a link to my CodePen containing the code.

3
  • 1
    This seems like an issue to file with CodePen directly. https://codepen.io/support/ Commented Jun 14, 2023 at 8:46
  • 1
    Looking for documentation of CodePen's AST parsing but can't find it directly. This question touches on what is happening in the background (though it is old) Strange JavaScript behavior in CodePen with humongous arrays Commented Jun 14, 2023 at 8:52
  • 1
    Alright, I've submitted it to CodePen support. Thanks Commented Jun 14, 2023 at 9:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.