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

Reporting the type of a variable

Objects and variables get confusing; save a few moments by making them report to us.

Getting ready

To test a battery of variables, one must instantiate a battery of variables.

// string variable, integer, array, object, null, undefined
var string_var = 'hello';
var integer_var = 1972;
var array_var = ['1','two',3];
var object_var = {one: '1', two: 'two', three: function() { alert(3); }}
var null_var;
//var oops_var; // commented out "on purpose"

How to do it...

Call a function that reports the type of each of our variables.

<h2>without moo:</h2>
<script type="text/javascript">
report_typeOf(0);
</script>
<h2><strong>with</strong> moo:</h2>
<script type="text/javascript">
report_typeOf(1);
</script>

How it works... ...

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