push array method code example
Example 1: js array add element
array.push(element)
Example 2: push array javascript
let array = ["A", "B"];
let variable = "what you want to add";
array.push(variable);
console.log(array);
Example 3: js push array
var array = [];
var element = "anything you want in the array";
array.push(element);
Example 4: array.push
var vegetables = ['Capsicum',' Carrot','Cucumber','Onion'];
vegetables.push('Okra');
Example 5: array push
arr.push([element1[, ...[, elementN]]])
Example 6: what does results.push({}) nodejs mean
const mongoose = require('mongoose');
var data = async function () {
var array = [];
const finalResults = await new Promise((resolve, reject) => {
mongoose.connection.collection("organizations").find({}).toArray(function(err, result) {
resolve(result);
});
});
for(var i = 0; i < finalResults.length; i++)
{
var a = finalResults[i].name;
array.push(a);
}
return array;
};
module.exports = {
data: data,
};