mootools
Not having internet at home for a month gave me a great opportunity to really study the MooTools core JavaScript file. One fun part of the library is its alias() functionality. Alias allows you to do exactly what the word means -- alias one functionality by calling it something else. For example, one usage of alias in the library is:
一个月没有在家上网,这给了我一个很好的机会来真正研究MooTools核心JavaScript文件。 库的一个有趣的部分是其alias()功能。 别名使您可以确切地实现该词的含义-通过调用其他功能来别名一种功能。 例如,库中别名的一种用法是:
Hash.alias('forEach', 'each'); //Hash iterationArray.alias('forEach', 'each'); //Array iteration
Using "each" is shorter and faster to type than "forEach." With aliasing in mind, I thought of a few fun usages of MooTools' alias. All of the following are aliases for the Element.dispose() functionality:
使用“ each”比“ forEach”更短,更快地键入。 考虑到别名,我想到了MooTools别名的一些有趣用法。 以下所有都是Element.dispose()功能的别名:
/* prison house */ Element.alias('dispose', 'shank'); $('prisoner').shank(); /* animals */ Element.alias('dispose', 'beach'); $('whale').beach(); /* automobiles */ Element.alias('dispose', 'compound'); $('car').compound(); /* mafia */ Element.alias('dispose', 'concreteShoes'); $('wiseguy').concreteShoes();
In all seriousness, I recommend using alias when you want to refer to a specific functionality by giving it your own name.
认真地说,当您要通过给自己命名的方式引用特定功能时,建议使用别名。
翻译自:
mootools