npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
https://stackoverflow.com/questions/45884752/npm-err-code-unable-to-get-issuer-cert-locally
npm config set registry http://registry.npmjs.org/
npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
https://stackoverflow.com/questions/45884752/npm-err-code-unable-to-get-issuer-cert-locally
npm config set registry http://registry.npmjs.org/
Map executes that callback on every element within it, returning a new array with all of the values that the callback returned. Map passes three arguments to your callback:
Filter takes an array, and filters out unwanted elements.Filter passes your callback three arguments:
Reduce takes all of the elements in an array, and reduces them into a single value. Reduce passes your callback four arguments:
var isEven = num => num % 2 === 0; var square = num => num * num; var add = (a, b) => a + b; var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; arr.filter(isEven).map(square).reduce(add); Output: 220
var people = [ {Name: "Jack Lee", Age: 21}, {Name: "Jack Ma", Age:31}, {Name: "Steve Liu", Age: 12}, {Name: "Alice Xu", Age: 42} ]; //Sort by name people.sort(function(a,b){ return (a.Name.toLowerCase() > b.Name.toLowerCase()) ? 1 : -1; }); //Sort by ES6 arrow function people.sort((a,b)=>{ return (a.Name.toLowerCase() > b.Name.toLowerCase()) ? 1 : -1; }); Sorted array by name: >people 0: {Name: "Alice Xu", Age: 42} 1: {Name: "Jack Lee", Age: 21} 2: {Name: "Jack Ma", Age: 31} 3: {Name: "Steve Liu", Age: 12} //sort by age people.sort(function(a,b){ return (a.Age > b.Age)? 1 : -1; }); //Sort by ES6 arrow function people.sort((a,b)=>{ return (a.Age > b.Age)? 1 : -1; }); Sorted array by age: >people 0: {Name: "Steve Liu", Age: 12} 1: {Name: "Jack Lee", Age: 21} 2: {Name: "Jack Ma", Age: 31} 3: {Name: "Alice Xu", Age: 42}