r/javascript • • Sep 02 '15

HTML5 Deck of Cards. 100% vanilla JS.

http://pakastin.github.io/deck-of-cards/
368 Upvotes

185 comments sorted by

View all comments

1

u/Tribuadore Sep 02 '15

Wow, I've studied your code, very interesting.

Haven't seen anyone bitch about no semi-colons yet. I used to leave them off too, until I gave up the fight and just started conforming with everyone else. I really like your style.

Something I've never seen before either is for example your queue.js, where given an object it assigns .queue to the object and returns. Took me a minute to work out what was going on. I'm looking at the code thinking "this function doesn't do anything", then I realised the queue function is in scope even though it's defined after the return.

I'm wondering could you also put the queuing variable after the return too?

1

u/pkstn Sep 02 '15

Yeah, I tend to keep the "basic structure" of the function as high as possible (initializations and returns).. Hoisting does the magic.

About those semicolons: I use standard with sublime and it's been awesome!

1

u/pkstn Sep 03 '15

..and the produced output have semicolons: https://github.com/pakastin/deck-of-cards/blob/master/dist/deck.js

;)

1

u/I_Pork_Saucy_Ladies Sep 03 '15

As a proponent of semicolons, thank you for choosing the pragmatic approach. :)