charAt
'0123'.charAt('1') // -> '1'
'0123'.charAt(1.45) // -> '1'
'0123'.charAt(true) // -> '1'
'0123'.charAt() // -> '0'
'0123'.charAt(NaN) // -> '0'
'0123'.charAt(-1) // -> ''
Number.prototype.charAt = String.prototype.charAt
NaN.charAt() // -> 'N'
Boolean.prototype.charAt = Boolean.prototype.charAt
true.charAt() // -> t
Funny snippet from Räphael’s creator Dmitry Baranovskiy’s talk Zen of JavaScript
Here is the part where he talks about this:
toString Radix
for (let i = 2; i < 36; i++) {
console.log((234).toString(i), ` = 234 in base ${i}`)
}
Use the radix argument of toString
Big Radio Button
document.body.innerHTML = `
<p>Click/tap the radio button:</p>
<input type="radio" style="transform:translate(20px, 30px) scale(4);background:red">
`;
I feel like at some point this didn’t work… nice to know it does now.
It will look different from browser to browser – as radio buttons do.
1×1 Transparent Image DataUri Gif
data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
Have used this one in the past – super useful – guessing I got it from here but not totally sure…
If I ever get around to making the updated version of QuickShader available – it’s used in there…
EDIT:
// ¯\_(:P)_/¯
Object.assign(document.createElement`canvas`,{width:1,height:1}).toDataURL()
//// ...
document.body.innerHTML=`<canvas id=x>`;x.width=x.height=1;x.toDataURL()