我很难理解为什么这件事不起作用。哪里有问题?这是将值传递给该函数的正确方法,还有其他方法吗?
seqer.set_prefix = 'Q';
seqer.set_seq = 1000;
是否可以这样做:
sequer.set_prefix('Q');
var serial_maker = function () {
var prefix = '';
var seq = 0;
return {
set_prefix: function (p) {
prefix = p;
},
set_seq: function (s) {
seq = s;
},
gensym: function () {
var result = prefix + seq;
seq += 1;
return result;
}
};
}();
var seqer = serial_maker();
seqer.set_prefix = 'Q'; // is this the right way to pass in values to this function, are there other ways? is it possible to write like this sequer.set_prefix('Q);
seqer.set_seq = 1000; // same here?
seqer.gensym()
;