javascript LightblueTomatoRaven由plastikaweb创建 - https://repl.it/@plastikaweb/LightblueTomatoRaven

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript LightblueTomatoRaven由plastikaweb创建 - https://repl.it/@plastikaweb/LightblueTomatoRaven相关的知识,希望对你有一定的参考价值。

const es6 = require('es6');
function LinkedList() {
  this.head = null;
  this.tail = null;
}

LinkedList.prototype.addToHead = function(value) {
  const newNode = new Node(value, this.head, null);
  if (this.head) {
    this.head.prev = newNode;
  } else {
    this.tail = newNode;
  }
  this.head = newNode;
};

LinkedList.prototype.addToTail = function(value) {
  const newNode = new Node(value, null, this.tail);
  if (this.tail) {
    this.tail.next = newNode;
  } else {
    this.head = newNode;
  }
  this.tail = newNode;
};

function Node(value, next, prev) {
  this.value = value;
  this.next = next;
  this.prev = prev;
}

var LL = new LinkedList();

LL.addToHead(100);
LL.addToHead(200);
LL.addToHead(300);

console.log(LL);

以上是关于javascript LightblueTomatoRaven由plastikaweb创建 - https://repl.it/@plastikaweb/LightblueTomatoRaven的主要内容,如果未能解决你的问题,请参考以下文章

javascript JavaScript isset()等效: - JavaScript

JavaScript 使用JavaScript更改CSS(JavaScript)

JavaScript之基础-1 JavaScript(概述基础语法)

前端基础-JavaScript的基本概述和语法

JavaScript

JavaScript