Created
August 11, 2017 15:43
-
-
Save hbt/3e71146454a2d6388338af1d76394a13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main() { | |
{ | |
let bb = doSomething1() | |
let mm = doSomething2(bb, 'ww') | |
} | |
function doSomething2(var1, var2) { | |
console.log('nnw') | |
} | |
function doSomething1() { | |
console.log('hh') | |
} | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/hbt/3e71146454a2d6388338af1d76394a13#file-test-js-L5
This part is defined first when you're thinking of what function should do
https://gist.github.com/hbt/3e71146454a2d6388338af1d76394a13#file-test-js-L6
Use
let
inside a block to prevent variables from leaking out and being used accidentally in functionshttps://gist.github.com/hbt/3e71146454a2d6388338af1d76394a13#file-test-js-L10
Inline functions are defined below and abstract a specific code block away but remain in the function to prevent unnecessary pollution and one-time use
https://gist.github.com/hbt/3e71146454a2d6388338af1d76394a13#file-test-js-L14
If a function needs to be reused, it can easily be extracted and refactored using IDE tools.