JSFiddle - React, Tailwind, and code Playground
by Alexander
JavaScript
console.clear();
var a = [1,2,3];
/*
const map = (a, f) =>
[ f(a.shift()), ...(a.length ? map(a, f) : []) ]
;
//*/
const map = (a, f) =>
[ f(a.slice(0,1)), ...(a.length > 1 ? map(a.slice(1,a.length), f) : [])]
;
console.log(
map(a, b => b * 2)
);
console.log(a);
/*
function map(a, cb) {
if (!map.a) map.a = [];
map.a.push( cb(a.shift()) );
if (a.length) return map(a, cb);
return map.a;
}
//*/