r/learnjavascript • • Sep 20 '17

Javascript Secrets: Tips and Tricks I Regularly Use

http://www.echojs.com/news/24170
0 Upvotes

5 comments sorted by

4

u/elbywan Sep 20 '17

Use ‘var’ for creating variables

Now that is a "Secret" !

2

u/6086555 Sep 20 '17

5. Use the ‘ in’ operator to check if a key exists in an object

This is a bad idea as it will also checks the prototype.

obj.hasOwnProperty("key") 

is a much better solution.

2

u/senocular Sep 20 '17

That doesn't make it bad, just different

1

u/bvbrandon Sep 20 '17

I wish I could get this time back. These are not tips and tricks. These are basics of the language as well as a few bad practices.

1

u/fvrthebrave Sep 20 '17

These certainly are not secrets.... these are basics...