Skip to content

Latest commit

 

History

History
48 lines (26 loc) · 1.8 KB

joelnet.md

File metadata and controls

48 lines (26 loc) · 1.8 KB

Developer JavaScript Joel

Tip # 1

Computed Properties are handy when you don't know the name of the property or the key contains special characters. A demo of this feature is set where the name is not known.

computed-property-1 computed-property-2

Tip # 2

🤔 Not sure why there's so much fear around the ternary operator. They don't appear to be much different than a switch or if. There are more similarities than differences

conditional-comparison

Tip # 3 Curring in JS

When you need to partially apply arguments to a function (partial application), consider currying the function. As a bonus, code can run after each argument is applied

currying-function-1

currying-function-2

For more information read the article Understanding Currying in JavaScript

Tip # 4

The 3 blocks of code on the left do the same thing. That is, they create a new instance of a function for every object created.

  • They do not reuse the prototype function
  • They become the same as the function on the right
  • These patterns are common in React

curried-usage

Tip # 5 💡 Turn any object into an Iterable

use Symbol.iterator to control how your object is iterated

symbol iterator

Tip # 6 💡 Simple closures can provide complex functionality

This example shows count in a closure, updated on every call to counter()

symbol iterator

⬆️ Back to top