function Lian(data,pre,next){ this.data = data; this.preNode = pre; if(this.preNode ){ pre.nextNode = this; } this.nextNode = next; } //輸入鏈表 Lian.prototype.aaa = function(){ if(this.nextNode){ return this.data.name + this.nextNode.aaa(); }else{ return this.data.name; } }; //插入節點 Lian.prototype.bbb = function(node){ if(this.nextNode && this.nextNode.preNode){ this.nextNode.preNode = node; } node.nextNode = this.nextNode; node.preNode = this; this.nextNode = node; }; //刪除節點 Lian.prototype.ccc = function(){ this.nextNode.preNode = this.preNode; this.preNode.nextNode = this.nextNode; }; var q = new Lian({"name": "1"}, null, null); var w = new Lian({"name": "2"}, q, null); var e = new Lian({"name": "3"}, w, null); var Head = q; console.log(Head.aaa());