Skip to content

Instantly share code, notes, and snippets.

View housecricket's full-sized avatar

Dang Trung Anh housecricket

View GitHub Profile
// ✗ avoid
function handler() {
this.logError(...)
}
// ✓ ok
function handler(context) {
context.logError(...)
}
+ '123' // ✗ avoid
Number('123) // ✓ ok
'' + true // ✗ avoid
String(true) // ✓ ok
var foo = new Foo // ✓ avoid
var foo = new Foo() // ✗ ok
class Rectangle {
constructor(height, width) {
this.height = height
this.width = width
this._area = height * width
}
}
const poly1 = new Polygon()
if (name === 'Trung Anh') // ✓ ok
if (name == 'Trung Anh') // ✗ avoid
// ✓ ok
var v
if (flag) {
v = x
} else {
v = y
}
// ✗ avoid
if (flag) {
var v = x
} else {
var v = y
}
// ✓ ok
var a = 2
var b = 3
var c = 4
var a = 2, b = 3, c = 4 // ✗ avoid