— Shang Liang

Silent Javascript Error in Safari

If you define a variable name as “private” in Javascript, Safari will terminate your code from there. It doesn’t give any error message. This only happens in Safari. IE/IE7, Mozilla Firefox and Opera don’t have this problem. I think the keyword “private” and “public” is conserved for some function in Safari, some OOP thing? Wasted quite a few hours in it…

2 comments
  1. Matt says: January 31, 20074:27 am

    Actually if you enable the javascript debugger in Safari you will get a ‘Parse Error’ warning informing you of the line number of your infraction… at least that helps narrow it down. I spent about 35 seconds on this problem, not the few hours mentioned above…

    The JS debugger is a lifesaver, enable it if you haven’t already.

  2. till says: May 25, 20079:06 pm

    “do” is also on this list of reserved variables.

    @Matt: Correct, I use the debugger as well, but still … ;-( Why is the browser conflicting with the user namespace?

Submit comment

For spam filtering purposes, please copy the number 4823 to the field below: