0

(JS) Private properties syntax highlighting issue

Hi all, I was working on a project and found that when using ES6 private object properties, the syntax highlighting fails (but the script runs correctly - see example). I was just curious if Iā€™m missing some non-fatal problem thatā€™s throwing the highlighting parser off, or if the highlighting just hasnā€™t been updated to reflect that structure. The error occurs in the ā€œWebā€ environment as well, but I didnā€™t want people to have to find the tab! Many thanks! https://code.sololearn.com/czFaWxC5pS52/?ref=app

19th Jul 2022, 4:19 AM
Jeremy Miller
3 Answers
+ 1
Jeremy Miller You cannot access private fields directly outside the class. So obj.#bar will give error. obj.bar is undefined because bar is not defined inside class.
19th Jul 2022, 4:41 AM
AĶ¢J
AĶ¢J - avatar
0
AĶ¢J I understand that. The script itself isnā€™t the issue; Iā€™m trying to understand why the syntax highlighting doesnā€™t work when private properties are included. I suspect itā€™s the parser but wanted to make sure.
19th Jul 2022, 4:52 AM
Jeremy Miller
0
Syntax highlighting is a human aid feature implemented in IDEs and code editors. But their highlighting preference may not represent engine's syntax recognition nor its ability in processing a code.
19th Jul 2022, 10:50 AM
Ipang