O'Reilly logo

YUI 3 Cookbook by Evan Goer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Utilities

Compared to other programming languages, JavaScript has historically included only a very small number of core utility methods. For years, if you wanted to trim whitespace from a string or enumerate an object’s keys, you had to implement that functionality yourself.

Recently, JavaScript has been evolving to fill in some of these feature gaps. Newer JavaScript engines still provide very minimal core APIs, but the environment at least is starting to look a little more like what developers coming over from other languages might expect.

As a comprehensive JavaScript framework, YUI provides a large number of utility methods. Some YUI utility methods mirror a native ECMAScript method, enabling you to use native code when that is available, but falling back to YUI code in older browsers. Other YUI utility methods provide a nicer or more powerful wrapper around a lower-level native API. Finally, some YUI utility methods provide high-level features or solve common problems that aren’t yet addressed by W3C or ECMAScript specifications.

This chapter provides a brief survey of some key YUI utilities, including language helpers (type checking, array and object manipulation) data converters, and formatters, application development (browser history), and form utilities (validation, keyboard and input change events).

As always, be sure to consult the YUI documentation in order to fully understand the API. Many recipes in this chapter show off only a small subset of what a particular ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required