Javascript: eval() and window.eval() Are Not The Same Thing

by Jon Davis 9. March 2010 03:32

I’ve been waiting for quite some time for my using.js project to pass all of its tests on Webkit and Opera. The last issue was the “retain context” issue, which wasn’t a using.js issue so much as a scenario issue, where if you declare a using block with using.js, the target object context for the “this” object was being retained in IE and in Firefox but not in Webkit nor in Opera. This issue revolved around the use of window.eval(), and I filed a bug report here:

https://bugs.webkit.org/show_bug.cgi?id=35722

.. as well as on Opera’s web site (no URL available as bug reports there are not public).

As is clearly observable in the history of the bug (bug title was changed by an Apple engineer) and in the comments of the bug, the scope and cause of the bug turned out to be more innocent than the browsers merely treating window.eval() differently. Although that remained true, it was irrelevant; I should have been using eval(), not window.eval().

The window.eval() function was the only eval() function I knew of. I had always assumed that eval() came about by way of the global window scope. But it appears that eval() is actually a standalone ECMAScript 5 operator now. This is interesting news! Who knew?!

So, note to self. From now on, never use window.eval()! Always use just eval().

And I’ve updated the using.js manual tests accordingly.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading




 

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Jon Davis (aka "stimpy77") has been a programmer, developer, and consultant for web and Windows software solutions professionally since 1997, with experience ranging from OS and hardware support to DHTML programming to IIS/ASP web apps to Java network programming to Visual Basic applications to C# desktop apps.
 
Software in all forms is also his sole hobby, whether playing PC games or tinkering with programming them. "I was playing Defender on the Commodore 64," he reminisces, "when I decided at the age of 12 or so that I want to be a computer programmer when I grow up."

Jon was previously employed as a senior .NET developer at a very well-known Internet services company whom you're more likely than not to have directly done business with. However, this blog and all of jondavis.net have no affiliation with, and are not representative of, his former employer in any way.

Contact Me 


Tag cloud

Calendar

<<  May 2020  >>
MoTuWeThFrSaSu
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

View posts in large calendar

RecentPosts