利用数组实现列表。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript实现列表</title>
</head>
<body>
<script>
/*定义List类及其拥有的属性和方法*/
function List(){
this.listSize = 0;/*列表长度*/
this.pos = 0;/*列表位置*/
this.dataStore = [];/*初始化一个空数组来保存列表*/
this.clear = clear;
this.find = find;
this.toString = toString;
this.insert = insert;
this.append = append;
this.remove = remove;
this.front = front;
this.end = end;
this.prev = prev;
this.next = next;
this.hasNext;
this.hasPrev;
this.length = length;
this.currPos = currPos;
this.moveTo = moveTo;
this.getElement = getElement;
this.contains = contains;
}
/*JavaScript实现List的方法*/
/*append:给列表添加元素*/
functi