array To List - Node.js Data Structure

Node.js examples for Data Structure:List

Description

array To List

Demo Code


function arrayToList(array) {
  var list = null
  for (var i=array.length-1;i>=0;i--) {
    var tempList = {}
    tempList.value = array[i]//w w w  .  jav a  2  s.  c om
    tempList.rest = list
    list = tempList
    // list.value = array[i]
    // list.rest = 
  }
  return list;
}

console.log(arrayToList([10, 20]));

Related Tutorials