The quickest way
Since the release of macOS Sierra, when in Finder, it is now possible to use the shortcut:
⌘ + ⇧ + .
Use terminal
Show files:
$ defaults write com.apple.finder AppleShowAllFiles YES; killall Finder
Hide files:
$ defaults write com.apple.finder AppleShowAllFiles NO; killall Finder