// use reduce function to find sum of all elements in array const array = [1,2,3,4,5]; const sumValue = array.reduce((sum, value)=> sum + value, 0); // 15 // check all the children is valid or not. root.children.every(child => !child) // filtering the values in JSON.stringify. const person = { name: "Ajaykumar", company: "eBay" } const output = JSON.stringify(person, (key,value) => { if(key === "company") return undefined; return value; }); console.log(output) // {"name":"Ajaykumar"} // check if its mac browser const isMac = /Mac|iPod|iPhone|iPad/.test(navigator.platform);