Use a function, like this:
var deck = {
suit: suit = ["Diamond", "Heart", "Club", "Spade"],
name: name = ["Nine", "Ten", "Jack", "Queen", "King", "Ace"],
cards: cards = [],
createcards:
function() {
for (var i = 0; i < suit.length; i++){
for (var j = 0; j < name.length; j++){
deck.cards.push(card(name[j], suit[i]))
}
}
},
draw: function (player){
randnumber = Math.floor((Math.random() * cards.length))
player.push[cards[randnumber]];
}
};
You can call the function inside the Object like this:
deck.createcards();
But I suggest that you look at the line with:
deck.cards.push(card(name[j], suit[i]))
because there is no function card here...