[Javascript] [solved ]Object Not Defined "isDefined" & "readFrom "method

Terry Riegel riegel at clearimageonline.com
Mon Nov 21 15:28:22 CST 2011


Troy,

As I think about it "isDefined" should return a boolean. Your function doesn't do that and it returns an error in Safari

Try this to duplicate it from the console...


> isDefined=function(x){try{return eval(x)}catch(e){return!1}}
> isDefined(a.b.c.d.e.f)

It doesn't return a boolean but throws an error. Also I wonder if there is a way to avoid using eval for this type of thing. Seems like it could be a security risk to fire up eval() just to see if something exists.

I will fiddle with it a bit to see if there might be another route.

Thanks,

Terry


On Nov 21, 2011, at 2:17 PM, Troy III Ajnej wrote:

> 
> 
> 
>  isDefined
>  ---------------------------8<------------------------------------------
>  /* b.b. Troy III p.a.e. */
>  isDefined=function(x){try{return eval(x)}catch(e){return!1}}
>  --------------------------->8------------------------------------------
> 
>  readFrom
>  -------------------------8<--------------------------------------------
>  /* b.b. Troy III p.a.e. */
>  readFrom=function(x,y){return isDefined(x)||y}
>  ------------------------->8--------------------------------------------
> 
>  usage
>  -------------------------8<--------------------------------------------
>  title=readFrom("a.b.c.d.e.f.g.h.i.j.k.title", "untitled");alert(title);
> 
>  [element].innerText=readFrom("a.b.c.d.e.f.g.h.i.j.k.title", "untitled");
>  -------------------------->8-------------------------------------------
> 
>  p.s.:
>  sorry about the mess, I'm posting from Chrome[!?!]. Let's see...
> 
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>                 Troy III
>        progressive art enterprise
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> 
> 
> 		 	   		  
> _______________________________________________
> Javascript mailing list
> Javascript at lists.evolt.org
> http://lists.evolt.org/mailman/listinfo/javascript

Terry Riegel

Put Your TimeClock on the Web
http://www.punchedin.com



More information about the Javascript mailing list