Answers for "nodjs how to add an array to function"

1

js add function to array

//create an new function that can be used by any array
Array.prototype.second = function() {
  return this[1];
};

var myArray = ["item1","item2","item3"];
console.log(myArray.second());//returns 'item2'
Posted by: Guest on April-08-2020
0

nodejs add to array

var colors=["red","white"];
colors.push("blue");//append 'blue' to colors
Posted by: Guest on February-23-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language