Skip to content

Instantly share code, notes, and snippets.

'use strict';
Array.prototype.reduce = function(callback, initialValue) {
let counter;
let accumulatedValue;
if (this.length === 0) {
return this;
} else {
if (arguments.length === 1) {
'use strict';
function reduce() {
var boxarts = [{
width: 200,
height: 200
}, {
width: 150,
height: 200
}, {
'use strict';
Array.prototype.concatAll = function() {
var results = [];
this.forEach(function(subArray) {
if (Array.isArray(subArray))
subArray.forEach((item) => results.push(item))
else
throw new Error('Its not two dimensional array;');
});
'use strict';
function queryNestedArray() {
var movieLists = [{
name: "New Releases",
videos: [{
"id": 70111470,
"title": "Die Hard",
"rating": 4.0
}, {
'use strict';
function chain() {
var newReleases = [{
"id": 70111470,
"title": "Die Hard",
"rating": 4.0
}, {
"id": 654356453,
"title": "Bad Boys",
'use strict';
function predicate() {
var newReleases = [{
"id": 70111470,
"title": "Die Hard",
"rating": 4.0
}, {
"id": 654356453,
"title": "Bad Boys",
'use strict';
Array.prototype.filter = function(Predicate) {
var result = [];
this.forEach(function(itemInArray) {
Predicate(itemInArray) ? result.push(itemInArray) : null;
});
return result;
'use strict';
function predicate() {
var newReleases = [{
"id": 70111470,
"title": "Die Hard",
"rating": 4.0
}, {
"id": 654356453,
"title": "Bad Boys",
'use strict';
function projection() {
var newReleases = [{
"id": 70111470,
"title": "Die Hard",
"rating": [4.0]
}, {
"id": 654356453,
"title": "Bad Boys",
'use strict';
Array.prototype.map = function(projectionFunction) {
var results = [];
this.forEach(function(itemInArray) {
results.push(projectionFunction(itemInArray));
});
return results;