Moon
Moon

Reputation: 22585

mootools hash() in jquery?

I have been using mootools for a year now. I need to use jquery for my new projects.

I always used hash() to make namespaces for my functions in mootools. For example,

var person = new Hash({
    say_name: function(){

    },
    say_age: function(){

    } 
});

Does Jquery has similar stuff?

Upvotes: 1

Views: 320

Answers (1)

jitter
jitter

Reputation: 54605

I don't think there is.

But you can just do

var person = {
    say_name: function() {
        ...
    },
    say_age: function(){
        ....
    } 
};
//and access like this
person.say_name();

The only difference is that the "convenience" functions provided by motools-Hash will be missing but the "namespace" effect is there.

And to be honest, after a quick look at the motools hash documentation, I bet you could reimplement most of the functions motools-Hash provides in a couple of minutes

Upvotes: 1

Related Questions