Skip to Main Content
MooTools 1.3 Cookbook
book

MooTools 1.3 Cookbook

by Jay L Johnston
July 2011
Intermediate to advanced content levelIntermediate to advanced
276 pages
5h 11m
English
Packt Publishing
Content preview from MooTools 1.3 Cookbook

Extending typeOf, fixing undefined var testing

In Chapter 9, WTFudge Is Going On?: Troubleshooting MooTools, a discussion of variable type reporting led us to an instance where we could not properly return the type of an undeclared variable. This oddity has its roots in the fact that undefined, undeclared variables cannot be dereferenced during a function call.

In short, undeclared variables can not be used as arguments to a function.

Getting ready

Get ready to see how we can still extend MooTools' typeOf function by passing a missing variable using the global scope:

// will throw a ReferenceError
myfunction(oops_var);
// will not throw a ReferenceError
myfunction(window.oops_var);

How to do it...

Extend the typeOf function with a new method and call ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Jump Start Web Performance

Jump Start Web Performance

Craig Buckler

Publisher Resources

ISBN: 9781849515689Other