You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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(typeofTAFFY!=='function'){
because it kept throwing a reference error. (TAFFY is undefined. Line: 42).
"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.
The text was updated successfully, but these errors were encountered:
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:
into this:
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.
The text was updated successfully, but these errors were encountered: