Skip to content

Instantly share code, notes, and snippets.

@baransu
Last active July 29, 2016 01:03
Show Gist options
  • Save baransu/b24b6344b37c746b2c536cfcba79b25d to your computer and use it in GitHub Desktop.
Save baransu/b24b6344b37c746b2c536cfcba79b25d to your computer and use it in GitHub Desktop.

##Ideas

###Tuple

 const a = ('hello', 'world')
 a._1 // 'hello'

to

const a = { _1: 'hello', _2: 'world'}
a._1 // 'hello'

###Functions

##Thinking

const mapStateToProps = ({ loading, locked, init, orderType, stateCounter, access }) => ({
  loading,
  locked,
  init,
  orderType,
  stateCounter,
  access
});

###Switch


This is horrible (change required)

  • variant A
switch(type) {
   case value: 
   break;
   
   default:
   break;
}
  • variant B
switch(type) {
   case value: 
     return ...;
   
   default:
     return ...;
}
  • variant C (for scope based variables const, let)
switch(type) {
   case value: {
     return ...
   }
   
   default: {
     return ...
   }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment