This file contains hidden or 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
///// Scopes ///// | |
- As little variables in global scope as possible | |
- iffes (immediately invoked function) are useful for creating closure and private variables | |
- Do not mutate inputs. But if you need to, be absolutely clear about it in your documentation | |
///// Closures ///// | |
- Functions create new closure scopes | |
- A closure is a function object that retains ongoing access to the variables of the context it was created in (even after the outer function calls it was created within have returned) |
This file contains hidden or 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
/////// Example of using Regexp with match in order to find the number of vowels in a string /////// | |
var vowelCount = function(str) { | |
var vowels = str.match(/[aeiou]/gi); | |
// if str was 'hi there', vowels is equal to ['i', 'e', 'e'] | |
return (vowels === null) ? 0 : vowels.length; | |
}; | |
/////// Example of how to use call to bind 'this' to the correct execution context /////// |
This file contains hidden or 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
///// Sublime Text 2 ///// | |
- Tools -> Build System -> Node: Command + B runs javascript console | |
- Tools -> Build System -> JSHint: Command + B checks javascript best practice syntax | |
- JavaScriptNext: better syntax highlighter | |
- SublimeOnSaveBuild: runs selected build system (see above) on save | |
///// Ghost ///// | |
- Blogging platform (npm start in ghost folder to launch) |
This file contains hidden or 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
///// Terminal ///// | |
ls - list of files in directory | |
ls -a - list of *all files in directory | |
cd - move into directory | |
ls -a subl .bash_profile - terminal shortcut editor | |
mkdir [dir name] - make new directory | |
touch [file name] - make new file | |
mv [file name] [new file name] - changes file name | |
cp [file name] - copies file or directory |