JSFiddle - React, Tailwind, and code Playground
by Ace Tributon
HTML
<div id='test'>
this is a test...
</div>
JavaScript
var revLoop=(item,out)=>{
for (i=item;i!=-1;i--){
out.call(this[i],this,i);
}
},
stored=['ree','rah','roo'];
revLoop(
stored.length-1, i=>
console.log(stored[i])
);
var x=[
[
(a, b) => document.querySelectorAll(a).forEach(b),
function(a, ...b) { x[0][0](a, i => i.innerHTML += b.join('')); return this;},
function(a, b) { x[0][0](a, i => i.style = b); return this;},
function(a, b) { for (i = 0; a[i]; i++) { b.call(b[i], i) } return this;}
],
[
[
'ree','roo','rah','oh crap!','well..'
]
]
];
x[0]
[1]('#test', 'plop', '<div class="demo">Here i am!</div>')
[2]('.demo', 'padding:2%;background-color:blue;color:white;')
[3](x[1][0], i => x[0][1]('.demo', `<p>${x[1][0][i]}</p>`))
;
return {
sel(a, b){document.querySelectorAll(a).forEach(b)},
addHTML(a, ...b) { this.sel(a, i => i.innerHTML += b.join(' ')); return this;},
addCSS(a, b) { this.sel(a, i => i.style = b); return this;},
loop(a, b) { for (i = 0; a[i]; i++) { b.call(b[i], i) } return this;},
opt(a, b, c) { return (a) ? (b) : (c)}
}
.addHTML('#test', 'MORE ROO', 'ree hee heee')
.addHTML('.demo', '<h3>yay more awesome stuff!</h3>')
.addHTML('#test', '<p>This isnt great only because you have to RECALL every data</p>')
.addCSS('h3', 'background-color:white;color:blue;padding:2%;')
;