是否有与MooTools Hash等效的jQuery? [英] Is there an jQuery equivalent of MooTools Hash?

查看:61
本文介绍了是否有与MooTools Hash等效的jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不认为jQuery具有Hash类,所以有一个等效类吗?

I don't think jQuery has a Hash class, so is there an equivalent?

我一直认为Object无论如何都能很好地完成哈希的工作.那么,除了MooTool的一些实用方法之外,MooTool的哈希还有什么特别之处?

I always thought Object does a good job hashing stuff anyway. So what's special about the MooTool's hash besides some of its utility methods?

推荐答案

我无法完全回答您的问题,因为我几乎不了解jquery,但我会尽力解释mootools中的哈希值,以便您可以尝试找到自己找到合适的解决方案

i can't answer your question in full as i know next to nothing about jquery but i will try to explain hashes in mootools so you can try and locate an appropriate solution yourself

基本上,mootools哈希的最佳部分是能够对对象进行原型制作,以便它们可以支持/继承通用方法(您无法在普通对象上执行此操作).

basically, the best part of the mootools hash is the ability to prototype objects so they can support/inherit common methods (which you can't do on a normal object).

例如,通过散列返回对象键的方法是var keys = new Hash({foo:'bar'}).getKeys();

for instance, the method that returns the object's keys through hash is var keys = new Hash({foo:'bar'}).getKeys();

因此,除了要继承框架的内置方法( http://mootools .net/docs/core/Native/Hash ),则可以通过Hash.implement对本地哈希值进行原型制作来定义自己的哈希值:

so in addition to inheriting the built-in methods by the framework (http://mootools.net/docs/core/Native/Hash), you can define your own by prototyping the hash native through Hash.implement:

Hash.implement({
    ismoo: function() {
        return this.hasValue("moo");
    }   
});

var f = new Hash({foo:'moo',moo:'cow'});
alert(f.ismoo());

我无法告诉您的是如何在jquery中复制此类功能-我想可以通过iirc $.fn.hasValue = function() { ... };或任何语法来扩展jQuery.

what i can't tell you is how to replicate such functionality in jquery - you can probably extend jQuery, i imagine through iirc $.fn.hasValue = function() { ... }; or whatever the syntax was.

无论如何-mootools是最重要的一点.哈希无法完成您无法以其他方式完成的任何事情,它操作起来很方便:)

anyway - bottom line is, mootools.Hash does not do anything you can't do yourself in a different way, it just does it conveniently well :)

这篇关于是否有与MooTools Hash等效的jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆