const numbers = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ]; //Transforms each element - map creates a new array by applying a function to every element of the original array. //Retun length of same array size. const double = numbers . map ( x => x * 2 ); console . log ( double ); const evenNumber = numbers . map ( x => x % 2 === 0 ); console . log ( evenNumber ); // Selects certain elements - filter creates a new array with only the elements that pass a test (predicate function). //Retun length of same or different array size. const filerResult = numbers . filter ( x => x > 3 ); console . log ( filerResult ); //Combine of filter and Map function const combine = numbers . filter ( x => x > 3 ). map ( y => y * 2 ); console . log ( combine ); //The reduce() method reduces an array to a single value by applying a function accumulatively (from left to right) to all elements. // Reduces array to a single value (e.g., sum) const sum = num...
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers