Create an array from a single value - Node.js Array

Node.js examples for Array:Array Value

Description

Create an array from a single value

Demo Code

Array.makeArray = function(value){
  if ( !value ) return [];
  if ( typeof value == "string" ) return [value];
  return Array.prototype.slice.call(value, 0);
};

Related Tutorials