Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(TAFFY is undefined. Line: 42). #49

Open
ghost opened this issue Jul 4, 2013 · 0 comments
Open

(TAFFY is undefined. Line: 42). #49

ghost opened this issue Jul 4, 2013 · 0 comments

Comments

@ghost
Copy link

ghost commented Jul 4, 2013

Hello,

I am currently planning on integrating TaffyDB into a framework I'm trying to build in ExtendScript, an extension of Ecma 262 edition 3 for the Adobe CS programs. In order to get TaffyDB to work with ExtendScript, I had to change the following line:

if ( ! TAFFY ){

into this:

if ( typeof TAFFY !== 'function' ){

because it kept throwing a reference error. (TAFFY is undefined. Line: 42).

Even though some libraries like the JSON library by Douglas Crockford for instance use this exact same technique, it says on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined that this technique is to be avoided:

"However, this kind of technique should be avoided. JavaScript is a statically scoped language, so knowing if a variable is defined can be read by seeing whether it is defined in an enclosing context. The only exception is the global scope, but the global scope is bound to the global object, so checking the existence of a variable in the global context can be done by checking the existence of a property on the global object (using the in operator, for instance)"

I'm not entirely sure why this technique is to be avoided, but I was hoping maybe some one could explain this to me why TAFFY uses if(! TAFFY) in stead of if( typeof TAFFY !== 'function').

Plus, I wanted to share this so that other developers facing the same issue would know where to look. I'm really glad I finally got it working, because TaffyDB is definitely going to save me a lot of dev-time ;)

Cheers,
p.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants