Javascript ++: How to Level Up Your Code

Try to Avoid Type Constructors

let x1 = new Object();
let x2 = new String();
let x3 = new Number();
let a1 = {};
let a2 = "";
let a3 = 0;

Use Strict Equals

"42" == 42
=> true
"42" === 42
=> false

Lots of Variables

function sayHello(options) {
let sentence = {
greeting: "Good morning!",
pleasantry: "How are you,",
name: "buddy",
exclamation: "?",
question: "some coffee?"
}
}
let name = "John"
let exclamation = "!?"
let question = "lunch?
function sayHello(, , name, question, exclamation)
=> "Good morning! How are you, John!? Do you want to grab lunch?"

Thoroughly Comment Your Code

//This code will greet a user upon loginfunction greeting() {
alert("Welcome!")
}

Passing Empty Parameters

method(...['parameter1', , 'parameter3'])

Bonus:

Full-Stack Developer, Software Engineer, and UX/UI Aficionado

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store