Return a clean native array

Following will convert a Live NodeList to a proper Array
@example
var childNodes = wysihtml5.lang.array(document.body.childNodes).get();
330397
function() {
      var i        = 0,
          length   = arr.length,
          newArray = [];
      for (; i<length; i++) {
        newArray.push(arr[i]);
      }
      return newArray;
    }
962151
function () {
            var childNodes = this.nodes();
            if (childNodes.length < 1) {
                return null;
            }
            var elementValue = '';
            for (var i = 0; i < childNodes.length; i++) {
                var node = childNodes[i];
                var valueToAdd;
                if (!TypeUtils.isNullOrUndefined(node.value)) {
                    valueToAdd = node.value;
                }
                else {
                    valueToAdd = node.toString();
                }
                if (!TypeUtils.isNullOrUndefined(valueToAdd)) {
                    elementValue += valueToAdd;
                }
            }
            return elementValue;
        }
856523
public function getTreeNodeParentArray()
    {
        $db = Database::connection();
        $nodeArray = [];
        $currentNodeParentID = $this->getTreeNodeParentID();
        if ($currentNodeParentID > 0) {
            while (is_numeric($currentNodeParentID) && $currentNodeParentID > 0 && $currentNodeParentID) {
                $row = $db->fetchAssoc('select treeNodeID, treeNodeParentID from TreeNodes where treeNodeID = ?', [$currentNodeParentID]);
                if ($row && $row['treeNodeID']) {
                    $nodeArray[] = self::getByID($row['treeNodeID']);
                }

                $currentNodeParentID = $row['treeNodeParentID']; // moving up the tree until we hit 1
            }
        }

        return $nodeArray;
    }
915782
def to_a
      ary = []
      node = @first_leaf
      while node do
        ary += node.values
        node = node.next_sibling
      end

      ary
    end
231596
public static function DOMNodeListToArray(DOMNodeList $nodeList, $associative = false, $attributes = false)
    {
        $nodes = array();

        foreach ($nodeList as $node) {
            $nodes[] = static::DOMNodeValue($node, $associative, $attributes);
        }

        return $nodes;
    }
1310510
function(arrayToSubstract) {
      arrayToSubstract = wysihtml5.lang.array(arrayToSubstract);
      var newArr  = [],
          i       = 0,
          length  = arr.length;
      for (; i<length; i++) {
        if (!arrayToSubstract.contains(arr[i])) {
          newArr.push(arr[i]);
        }
      }
      return newArr;
    }
561174
public function asArray()
    {
        $error = $this->error;
        if ($error->has()) {
            $o = [
                'error' => true,
                'errors' => [],
                'htmlErrorIndexes' => [],
            ];
            $index = 0;
            foreach ($error->getList() as $error) {
                $o['errors'][] = (string) $error;
                if ($error instanceof HtmlAwareErrorInterface && $error->messageContainsHtml()) {
                    $o['htmlErrorIndexes'][] = $index;
                }
                ++$index;
            }
            if (empty($o['htmlErrorIndexes'])) {
                unset($o['htmlErrorIndexes']);
            }

            return $o;
        }
    }
1343286
public ClassNode makeArray() {
        if (redirect!=null) {
            ClassNode res = redirect().makeArray();
            res.componentType = this;
            return res;
        }
        ClassNode cn;
        if (clazz!=null) {
            Class ret = Array.newInstance(clazz,0).getClass();
            // don't use the ClassHelper here!
            cn = new ClassNode(ret,this);
        } else {
            cn = new ClassNode(this);
        }
        return cn;
    }
1154211
@SuppressWarnings("unchecked")
	public JSONNavi<T> array() {
		if (failure)
			return this;
		if (current == null && readonly)
			failure("Can not create Array child in readonly", null);
		if (current != null) {
			if (isArray())
				return this;
			if (isObject())
				failure("can not use Object feature on Array.", null);
			failure("Can not use current possition as Object", null);
		} else {
			current = mapper.createArray();
		}
		if (root == null)
			root = (T) current;
		else
			store();
		return this;
	}
298508
protected function childrenAsArray($nodeList)
	{
		$result = array();
		if (! is_object($nodeList))
		{
			return $result;
		}

		if (! ($nodeList instanceof DOMNodeList))
		{
			return $result;
		}

		for ($i = 0; $i < $nodeList->length; $i++)
		{
			$result []= $nodeList->item($i);
		}

		return $result;
	}
706175
@Override
	public Object[] toArray() {
		Object[] result = new Object[size];
		for(int c=0;c<size;c++) result[c] = elementData[c];
		return result;
	}
417875
function makeArray( obj ) {
  var ary = [];
  if ( isArray( obj ) ) {
    // use object if already an array
    ary = obj;
  } else if ( typeof obj.length === 'number' ) {
    // convert nodeList to array
    for ( var i=0, len = obj.length; i < len; i++ ) {
      ary.push( obj[i] );
    }
  } else {
    // array of single index
    ary.push( obj );
  }
  return ary;
}
874593
function nodeCopy(a)
{
	var newA = {
		ctor: '_Array',
		height: a.height,
		table: a.table.slice()
	};
	if (a.height > 0)
	{
		newA.lengths = a.lengths.slice();
	}
	return newA;
}
888078
function cleanDom(dom) {
  var result = [];
  for(var i=0;i<dom.length;i++) {
    var node = dom[i];
    //console.log(node);
    if(node.type=='directive') continue;
    if(node.type=='tag') {
      var k = node.name;
      var v = node.attribs || {};
      var obj = {};
      obj[k] = v;
      if(node.hasOwnProperty("children")) {
        //console.log(node.children);
        //console.log(cleanDom(node.children));
        _.each(cleanDom(node.children), function(o) { 
          if(!_.isObject(o) || !_.isObject(v)) {
            if(_.isObject(v)) {
              if(_.size(v)==0) {
                v=o;
              } else {
                v['_text']=o;
              }
            }  else if(_.isArray(v)) {
              v.push(o); 
            } else {
              v=[v];
              v.push(o);
            }
            obj[k] = v;
          } else {
            // first step is to merge same key items
            // basically convert them to arrays
            var sameKeys = _.intersection(_.keys(o), _.keys(v));
            _.each(sameKeys, function(k) {
              if(!_.isArray(v[k])) {
                v[k]=[v[k]];
              }
              v[k]=v[k].concat(o[k]);
            });
            var remainingObj = _.omit(o, sameKeys);
            _.extend(v, remainingObj); 
          }
        });
      }
      result.push(obj);
    }
    if(node.type=='text') {
      result.push(node.data);
    }
  }
  //console.log(result);
  return result;
}
990851
static String[] listToArray(List<String> elements, String defaultValue){
        if (elements == null || elements.isEmpty()) return new String[]{defaultValue};

        String[] elementsArr = new String[elements.size()];
        elements.toArray(elementsArr);

        return elementsArr;
    }
1321645
private function getArrayFromElementsByTagName ($rawXml, $tag, $namespace = NULL) {
		// Get DOM instance and load XML
		$dom = new \DOMDocument();

		$dom->loadXML($rawXml, (LIBXML_VERSION >= 20900) ? LIBXML_PARSEHUGE : null);

		// Is namespace set?
		if (!is_null($namespace)) {
			// Use it
			$nodes = $dom->getElementsByTagNameNS($tag, $namespace);
		} else {
			// Get nodes
			$nodes = $dom->getElementsByTagName($tag);
		}

		// Return nodes list
		return $nodes;
	}
1157105
function isNodeList(nodes) {
  var stringRepr = Object.prototype.toString.call(nodes)

  return typeof nodes === 'object' &&
    /^\[object (HTMLCollection|NodeList|Object)\]$/.test(stringRepr) &&
    (typeof nodes.length === 'number') &&
    (nodes.length === 0 || (typeof nodes[0] === "object" && nodes[0].nodeType > 0))
}