var cart = { _wheels: 4, get _wheels () { return this._wheels;//Maximum call stack size exceeded }, set _wheels (value) { if (value < this._wheels) { throw new Error('數值太小了!'); } this._wheels = value; }}console.log(cart._wheels);cart._wheels = 1;console.log(cart._wheels);
js中get set 的用處體現在哪里?死循環?
守候你守候我
2018-08-06 11:11:16