這是我的代碼:參數傳遞到嵌套函數
var Placemat = function(id,id2) {
this.hand = document.getElementById(id);
this.bucket = "";
this.bucketspace = document.getElementById(id2);
this.bucketvalue = 0;
var that = this;
this.deal = function(id) {
shuffle();
var card1 = deck.shift();
var card2 = deck.shift();
this.hand.innerHTML = card1 + ", " + card2;
};
this.hit = function(id2) {
var card3 = deck.shift();
this.bucket = this.bucket + deck.shift();
this.bucketspace.innerHTML = this.bucket;
};
};
這是傳遞參數給一個嵌套函數的正確方法?這id
和id2
在this.deal()
和this.hit()
是從Placemat()
。
我不明白參數是什麼? – zwol