I'm currently trying to create a private variable in a class, I currently have:
- $.Class('Card', {
card_id: 0
},{
init: function(suit, value) {
_id = this.constructor.card_id;
this.get_id = function() {
return _id;
}
this.suit = suit;
this.value = value;
this.constructor.card_id++;
}
});
The problem here is, once I create a bunch of cards, for some reason all of their ID's have the same ID (I create 52 cards, they all have an ID of 51). When I change "_id" to "this.id" though, it acts as expected with each having their own unique ID, but I would like to make that private.
Thanks!