编程知识 cdmana.com

JS algorithm

1、 Array

JavaScript An array in is a special object , The index used to represent the offset is a property of the object , The index may be an integer . However , These numeric indexes are internally converted to string type , This is because JavaScript The property name in the object must be a string . Array in JavaScript It's just a special object , So it's not as efficient as arrays in other languages .

JavaScript In the array , Strictly speaking, it should be called an object , It's special JavaScript object , Is classified internally as an array . because Array stay JavaScript Is treated as an object , So it has many properties and methods that can be used in programming .
There are two ways to convert an array into a string :join() and toString(). Both methods return a string containing all the elements of the array , The elements are separated by commas .
concat() and splice() Method allows you to create a new array from an existing array .

2、 list

function List() {
    this.listSize = 0;
    this.pos = 0;
    this.dataStore = []; // Initialize an empty array to hold the list elements 
    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.length = length;
    this.currPos = currPos;
    this.moveTo = moveTo;
    this.getElement = getElement;
    this.contains = contains;
}

版权声明
本文为[stray]所创,转载请带上原文链接,感谢

Tags js algorithm
Scroll to Top