r/javascript • • Mar 18 '19

What's your favorite, most useful javascript one-liner?

385 Upvotes

422 comments sorted by

View all comments

Show parent comments

2

u/[deleted] Mar 20 '19

Can’t you also use 3 digit hex for some colors?

1

u/senocular Mar 20 '19

Yup, so technically not all values 0xFFFFF and below will be invalid. There will be a range within 0x100 and 0xFFF that will be OK. But these are also not representative of their random values. The 3 digit hex for colors is shorthand for #RGB -> #RRGGBB. So if #100 popped out, its hex value would really be #110000 and not the actual random value of #000100. This means you're also increasing the odds of #RRGGBB-formatted colors to be hit ;)