Guess the semi-golf
a=3217+'';a=[a];console.log(a[0][2])
Try and guess what would be logged here…
b = document.body
with(b.style)
fontFamily = 'monospace', fontSize = '2em',
transform = 'skew(10deg) translateX(40px)'
N = '<br>';
(f=(_='*')=>(
b.innerHTML+=` <b style='opacity:${Math.random()+.2}'>${_}</b>`,f))('<pre>')
( )( )( )( )(N)
('(')('0')('_')('_')(N)
('-')( )( )('-')(N)
('_')('_')('0')(')')(N)
('-')( )( )('-')(N)
('(')('0')('_')('_')(N)
('-')( )( )('-')(N)
('_')('_')('0')(')')(N)
('-')( )( )('-')(N)
('(')('0')('_')('_')(N)
( )( )( )( )
Not really sure what this is… just playing around…
console.log([100, 200, [2], [3, 4, [2, 3, [5]], 100]]+'')
// outputs: "100,200,2,3,4,2,3,5,100"
Coercing a multidimensional array to a string flattens it and joins it with commas
d = document
b = d.body
with(
b.appendChild(Object.assign(
d.createElement`canvas`, { width: 100, height: 100 })
).getContext`2d`) {
fillStyle = 'red'
fillRect(5, 5, 20, 20)
}
// slightly more complex example
with(
b.appendChild(Object.assign(
d.createElement`canvas`, { width: 200, height: 200 })
).getContext`2d`) {
fillStyle = '#555', strokeStyle = '#fff', fillRect(0, 0, 200, 200)
for (i = 0; i < 10; i++)
beginPath(), moveTo(20, 20), lineTo(i * 20 + 10, 190), stroke()
}
Easy way to write canvas stuff with very little boilerplate code.