我试过调试,但还没有运气!这有效:
function slider(direction){
this.direction = direction;
}
slider.prototype.move = function(){
console.log('moving');
};
var slider1 = new slider('backward');
console.log(slider1.direction);
var slider2 = new slider('forward');
console.log(slider2.direction);
这不起作用:
var slider = new slider('backward');
console.log(slider.direction);
var slider2 = new slider('forward');
console.log(slider2.direction);
我知道这与分号有关,我搜索了其他一些关于此的文章,但找不到我的问题的答案