r/javascript • • Mar 09 '15

Things every JavaScript developer should know

http://ilikekillnerds.com/2015/03/things-every-javascript-developer-should-know/
326 Upvotes

118 comments sorted by

View all comments

-1

u/[deleted] Mar 09 '15

I disagree about call and apply though. I prefer to never use:

  • new

  • this (one exception)

  • Object.create

  • bind

  • call

  • apply

When I avoid this list my code tends to be smaller and faster to execute. You don't need OOP in this language, thanks to lexical scope, to achieve decomposable reuse and reference sharing.

The one exception for this is event handlers where it is commonly necessary to access the event target without access to an explicit reference.

3

u/[deleted] Mar 09 '15

[removed] — view removed comment

-4

u/[deleted] Mar 09 '15

You are being silly. You don't need to specify arguments or an explicit return value to achieve functional programming. Functional programming is not about using functions to pass things around (as a substitute for objects). It is about organizing instructions into containers that can be executed without regard for a returned value.

2

u/[deleted] Mar 09 '15

[removed] — view removed comment

-3

u/[deleted] Mar 09 '15

I don't know what a partial function is, but it sounds like something I would never do.

7

u/[deleted] Mar 09 '15

[removed] — view removed comment

0

u/[deleted] Mar 09 '15 edited Mar 09 '15

I don't use call or apply because they are unnecessary. I don't use the arguments array in functions. arguments is generally considered very bad form, because it allows use of arguments with flexibility to types and quantity of arguments passed into the function. This is makes it hard for the JIT compilers to compile those functions, which means the code will execute far more slowly.