Search

12/20/2007

yui useful functions

YAHOO.lang.dump

 var t = {
'who': 'foo',
'email': 'foo@example.com',
'c': function(){
alert( 'who:' + this.who + ' email:' + this.email )
}
}
alert(YAHOO.lang.dump(t));
//{who => foo, email => foo@example.com, c => f(){...}}

YAHOO.lang.trim
Returns a string without any leading or trailing whitespace. If the input is not a string, the input will be returned untouched.

 var t = '  example string  ';
YAHOO.lang.trim(t);
alert('|' + t + '|');
alert('|'+ YAHOO.lang.trim(t) + '|');
//| example string |
//|example string|

沒有留言: