
function eventHandler(ev) {
if (!ev) ev = window.event;
var target = ev.target ? ev.target : ev.srcElement;
if (target.nodeType == 3) // Safari bug
target = target.parentNode;
}
(ie.microsoft.com/testdrive/benchmarks/sunspider/default.html)
var a = 1, b = 2;
function printVars() {
console.log(a, b); // undefined, 2
var a = 5;
console.log(a); // 5
}
var a;
var b;
a = 1;
b = 2;
function printVars() {
var a;
console.log(a, b); // undefined, 2
a = 5;
console.log(a); // 5
}
function sayHello() {
return
"Hello, World";
}
console.log(sayHello()); // undefined
function sayHello() {
return;
"Hello, World";
}
console.log(sayHello()); // undefined
var friend = true;
if (friend)
function say() { return "xo"; }
else
function say() { return "fu"; }
console.log(say()); // "fu"
function say() { return "xo"; }
function say() { return "fu"; }
var friend;
friend = true;
if (friend) {}
else {}
console.log(say()); // "fu"
lint—a program that flagged suspicious and non-portable constructs in C code
npm install jshint && jshint ./jquery.jsJSHINT(code, options, globals);var Slides = { /* implementation */ };
window.addEventListener('message', function (event) {
if (event.data == 'next')
slides.nextSlide();
else if (event.data == 'prev')
Slides.prevSlide();
else
console.log('lolwat?');
});
var Slides = { /* implementation */ };
window.addEventListener('message', function (event) {
if (event.data == 'next')
slides.nextSlide();
else if (event.data == 'prev')
Slides.prevSlide();
else
console.log('lolwat?');
});
// >> Implied globals: window, slides, Slides, console
/*jshint undef:true */
var Slides = { /* implementation */ };
window.addEventListener('message', function (event) {
if (event.data == 'next')
slides.nextSlide();
else if (event.data == 'prev')
Slides.prevSlide();
else
console.log('lolwat?');
});
/*jshint undef:true */
var Slides = { /* implementation */ };
window.addEventListener('message', function (event) {
if (event.data == 'next')
slides.nextSlide();
else if (event.data == 'prev')
Slides.prevSlide();
else
console.log('lolwat?');
});
// >> Errors:
// >> Line 5: window is not defined
// >> Line 7: slides is not defined
// >> Line 11: console is not defined
/*jshint undef:true */
/*globals Slides:true, window:false, console:false */
var Slides = { /* implementation */ };
window.addEventListener('message', function (event) {
if (event.data == 'next')
slides.nextSlide();
else if (event.data == 'prev')
Slides.prevSlide();
else
console.log('lolwat?');
});
/*jshint undef:true */
/*globals Slides:true, window:false, console:false */
var Slides = { /* implementation */ };
window.addEventListener('message', function (event) {
if (event.data == 'next')
slides.nextSlide();
else if (event.data == 'prev')
Slides.prevSlide();
else
console.log('lolwat?');
});
// >> Errors:
// >> Line 8: slides is not defined
/*jshint jquery:true */
if (jQuery == null) {
console.log("No jQuery");
}
(function () {
/*jshint eqnull:true */
if (jQuery == null) {
jQuery = {};
}
}());
/*jshint jquery:true */
if (jQuery == null) { // Use '===' to compare with 'null'
console.log("No jQuery");
}
(function () {
/*jshint eqnull:true */
if (jQuery == null) {
jQuery = {}; // Read only.
}
}());
# Source/disqus/.git/hooks/pre-commit
import os
def main():
"Checks your git commit with PyFlakes and JSHint"
# [...]
results = {}
for file in get_files_changed("*.js"):
status, output = jshint(file)
if status:
results[file] = output
if results:
print_errors(results)
sys.exit(1) # Abort the commit
sys.exit(0) # All good
But authors can skip our hooks by using the git-commit -n option

You want to contribute but your company doesn't encourage spending time on open source projects?