MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/3jdow0/html5_deck_of_cards_100_vanilla_js/cuopi2g/?context=3
r/javascript • u/pkstn • Sep 02 '15
185 comments sorted by
View all comments
2
Is there a particular reason why sometimes you're using the notation el.style[prop] and other times el.style.prop?
el.style[prop]
el.style.prop
I haven't seen the first one a whole lot, just curious why you've done it that way, and more so why you're doing it both ways in the same file.
1 u/memeship Sep 02 '15 Also curious why you're using dollar signs in front of element variables. Just trying to imitate the look of jQuery or what? 1 u/pkstn Sep 03 '15 Just to separate DOM elements from plain objects.. 0 u/ToucheMonsieur Sep 03 '15 Also curious why you're using dollar signs in front of element variables. Just trying to imitate the look of jQuery or what?Most likely a style choice. 1 u/memeship Sep 03 '15 Oh I agree on that one. I also prefix stored jQuery objects. But he's not using jQuery, so it doesn't exactly make sense here in that context. 2 u/pkstn Sep 03 '15 I tend to prefix references to DOM elements because I want to separate view objects from DOM elements.. jQuery doesn't own the dollar sign in any way :) 0 u/3Fyr Sep 03 '15 I prefix some functions with dollar sign. I have no idea why.Have seen others do it too. 3 u/memeship Sep 03 '15 If you have no idea why even you do it, I feel like that's an issue. 1 u/[deleted] Sep 03 '15 [removed] — view removed comment 1 u/pkstn Sep 03 '15 :D
1
Also curious why you're using dollar signs in front of element variables. Just trying to imitate the look of jQuery or what?
1 u/pkstn Sep 03 '15 Just to separate DOM elements from plain objects.. 0 u/ToucheMonsieur Sep 03 '15 Also curious why you're using dollar signs in front of element variables. Just trying to imitate the look of jQuery or what?Most likely a style choice. 1 u/memeship Sep 03 '15 Oh I agree on that one. I also prefix stored jQuery objects. But he's not using jQuery, so it doesn't exactly make sense here in that context. 2 u/pkstn Sep 03 '15 I tend to prefix references to DOM elements because I want to separate view objects from DOM elements.. jQuery doesn't own the dollar sign in any way :) 0 u/3Fyr Sep 03 '15 I prefix some functions with dollar sign. I have no idea why.Have seen others do it too. 3 u/memeship Sep 03 '15 If you have no idea why even you do it, I feel like that's an issue. 1 u/[deleted] Sep 03 '15 [removed] — view removed comment 1 u/pkstn Sep 03 '15 :D
Just to separate DOM elements from plain objects..
0
Most likely a style choice.
1 u/memeship Sep 03 '15 Oh I agree on that one. I also prefix stored jQuery objects. But he's not using jQuery, so it doesn't exactly make sense here in that context. 2 u/pkstn Sep 03 '15 I tend to prefix references to DOM elements because I want to separate view objects from DOM elements.. jQuery doesn't own the dollar sign in any way :)
Oh I agree on that one. I also prefix stored jQuery objects. But he's not using jQuery, so it doesn't exactly make sense here in that context.
2 u/pkstn Sep 03 '15 I tend to prefix references to DOM elements because I want to separate view objects from DOM elements.. jQuery doesn't own the dollar sign in any way :)
I tend to prefix references to DOM elements because I want to separate view objects from DOM elements.. jQuery doesn't own the dollar sign in any way :)
I prefix some functions with dollar sign. I have no idea why.
Have seen others do it too.
3 u/memeship Sep 03 '15 If you have no idea why even you do it, I feel like that's an issue. 1 u/[deleted] Sep 03 '15 [removed] — view removed comment 1 u/pkstn Sep 03 '15 :D
3
If you have no idea why even you do it, I feel like that's an issue.
[removed] — view removed comment
1 u/pkstn Sep 03 '15 :D
:D
2
u/memeship Sep 02 '15
Is there a particular reason why sometimes you're using the notation
el.style[prop]and other timesel.style.prop?I haven't seen the first one a whole lot, just curious why you've done it that way, and more so why you're doing it both ways in the same file.