Setup based off this article: https://hackernoon.com/these-6-essential-tools-will-maintain-your-npm-modules-for-you-4cbbee88e0cb
| class Counter { | |
| constructor() { | |
| this.count = 5 | |
| this.add = function() { | |
| this.count++ | |
| } | |
| } | |
| copy() { |
prettier-eslint |
eslint-plugin-prettier |
eslint-config-prettier |
|
|---|---|---|---|
| What it is | A JavaScript module exporting a single function. | An ESLint plugin. | An ESLint configuration. |
| What it does | Runs the code (string) through prettier then eslint --fix. The output is also a string. |
Plugins usually contain implementations for additional rules that ESLint will check for. This plugin uses Prettier under the hood and will raise ESLint errors when your code differs from Prettier's expected output. | This config turns off formatting-related rules that might conflict with Prettier, allowing you to use Prettier with other ESLint configs like eslint-config-airbnb. |
| How to use it | Either calling the function in your code or via [prettier-eslint-cli](https://github.co |
| 'use strict'; | |
| class Abstract { | |
| // A static abstract method. | |
| static foo() { | |
| if (this === Abstract) { | |
| // Error Type 2. Abstract methods can not be called directly. | |
| throw new TypeError("Can not call static abstract method foo."); | |
| } else if (this.foo === Abstract.foo) { | |
| // Error Type 3. The child has not implemented this method. | |
| throw new TypeError("Please implement static abstract method foo."); |
| /* Client side, works in Chrome 55 and Firefox 52 without transpilation */ | |
| //https://blogs.msdn.microsoft.com/typescript/2016/11/08/typescript-2-1-rc-better-inference-async-functions-and-more/ | |
| async function fetchURLs() { | |
| try { | |
| // Promise.all() lets us coalesce multiple promises into a single super-promise | |
| var data = await Promise.all([ | |
| /* Alternatively store each in an array */ | |
| // var [x, y, z] = await Promise.all([ | |
| // parse results as json; fetch data response has several reader methods available: | |
| //.arrayBuffer() |
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
- Follow standard conventions.
- Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
- Boy scout rule. Leave the campground cleaner than you found it.
- Always find root cause. Always look for the root cause of a problem.
Just migrated it from Codepen.io to markdown. Credit goes to David Conner.
| Working with DOM | Working with JS | Working With Functions |
|---|---|---|
| Accessing Dom Elements | Add/Remove Array Item | Add Default Arguments to Function |
| Grab Children/Parent Node(s) | Add/Remove Object Properties | Throttle/Debounce Functions |
| Create DOM Elements | Conditionals |
| // change to false if its not imported into bootstrap | |
| $use-bootstrap: true; | |
| // margin and padding values array | |
| $space-values : ( | |
| 5, | |
| 10, | |
| 15, | |
| 20, | |
| 30, |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft,elem.offsetTop,elem.offsetWidth,elem.offsetHeight,elem.offsetParent
I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\