# Javascript

## Code Style

* [Info](https://javascript.info/coding-style)
* [Google Style](https://google.github.io/styleguide/jsguide.html)
* [StandardJS](https://standardjs.com/)
* General guide
  * Indentation : +2 spaces
  * A line space between code block
  * Column limit : 80
  * Use single quote `'` for strings
  * Use `===` for equality check
  * A space between `:` and value in key-value pair

### [ESLint](https://eslint.org/)

* Install package

```sh
$ npm install -g eslint

```

* Create `.eslintrc` config file

```json
{
  "extends": "eslint:recommended",
  "env": {
    "browser": true,
    "node": true,
    "es6": true
  },
  "rules": {
    "no-console": 0,
    "indent": 2
  }
}
```



* NVM use issue
  * Delete/remove/uninstall the version of node in your "C:\Program Files\nodejs" directory. To the point where there is no more "nodejs" directory at all.
  * Delete the existence of nvm (C:\Users\xxx\AppData\Roaming\nvm), basically, manually delete the nvm dir.
  * Download your desired version of nvm (https://github.com/coreybutler/nvm-windows/releases)
  * Open a CMD prompt (run as administrator), and install the downloaded version of nvm, nvm-setup.exe, from within this CMD command prompt.
  * From within the admin level command prompt, run "nvm install 7.2.1", or whatever node version you want to install. Probably you will be installing multiple versions, so repeat as needed.
  * Now do the usual "nvm use ...", "nvm list", etc...