Front-End Code Quality @ Panaya
In Client side we code in ?
LET'S FOCUS ON
In shorts
used to create interactive websites
(function() {
var a = "initial";
if(a) {
function f() { console.log("1") };
} else {
function f() { console.log("2") };
}
f();
})()
What would be printed
1 ?
2 ?
Internet Explorer
1
Chrome
2
Opera
console.log(typeof greet);
greet();
var greet = function() {
alert("hello!");
}
console.log(typeof greet);
greet();
function greet() {
alert("hello!");
}
VS.
> 0 == false
true
> 1 == true
true
> 2 == true
false
> 2 ? true : false
true // because 2 !== 0
'' == '0' // false
0 == '' // true
0 == '0' // true
false == 'false' // false
false == '0' // true
false == undefined // false
false == null // false
null == undefined // true
' \t\r\n ' == 0 // true
if(undefined = "foo") {
...
}
//OH NO YOU DIDN'T!!
STATIC CODE ANALYSIS
"Lint" tools read your source code and look for common mistakes...
It will not make you a better coder ;)
(function() {
var a = "initial";
if(a) {
function f() { console.log("1") };
} else {
function f() { console.log("2") };
}
f();
})()
"NO INNER FUNCTION DECLARATION"
WINNER: ES-LINT
Currently - during "Compile" stage
From "Day after 10.2"
I am sending list of errors every Sunday to TL