Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bad JS advice
# window.onerror
Not needed anymore now dev tools are so sophisticated, you can tell the browser to pause on error and then get a full stack trace and a list of all variables in the current scope.
# Don't tell people to do this:
```
var calc = function calc (a, b) { return a * b; }
```
Devs should define functions with the function reserved word first, i.e...
```
function calc (a, b) { return a * b; }
```
The only time you'd want to assign a function to something is a property to an object.
# micro optimisations
Don't do them if you are making the code harder to read, this is perfectly acceptable...
Speak to mark about this:
# self defining courses
```
var scareMe = function(){
console.log("Boo!");
scareMe = function(){
console.log("Double Boo!");
}
}
scareMe(); //==>Boo!
scareMe(); //==>Double Boo!
```
I'm confused about how this would work within the concept of OO/functional programming, this is essentially a singleton and is considered bad practice.
# Chaining - chaining promotes doing lots of things in one go, this is a potential code smell and developers should be made aware of the dangers of chaining
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment