isNaN
So, null is not an object though sometimes null is a Number.
isNaN( null ); // false
null === NaN; // false
null == NaN; // false
isNaN converts null to number.
Number( null ); // 0
But WTF. :) - @oleg008
So, null is not an object though sometimes null is a Number.
isNaN( null ); // false
null === NaN; // false
null == NaN; // false
isNaN converts null to number.
Number( null ); // 0
But WTF. :) - @oleg008
This is much more awesome. I have to thank the guys at HowToNode.org for the idea in thier WheatJS static site blog engine. Essentially, it all boils down to running the rather awesome Google Code Prettyfy serverside.
The only remaining problem with the syntax highlighting is now nested <code> elements have to be escaped to display correctly in the final render.
// replace the raw code blocks with prettyfied html
t = t.replace(/<code>[^<]+<\/code>/g, function(code) {
return prettyfy(code.match(/<code>([\s\S]+)<\/code>/)[1]);
});
Perhaps, in the future, a quick routine to fetch only the root code elements rather than blinding fetching all of them. Problem: more solved than before!
@ThomasFuchs throws down this obfuscated beauty:
1 + + 1 // => 2
1 + - + 1 // => 0
1 + - + - + 1 // => 2
1 + - + - + - + 1 // => 0
1 + - + + + - + 1 // => 2
1 + / + + + / + 1 // => 1/ + + + /1
An update by @deadlyicon on the previous post.
This is just a really silly way of saying this:
Function.prototype.call.apply(function (a) {return a}, [1,2])
// 2
If this still seems weird to you. Consider this:
function logThisAndArgs() {
console.log(this, arguments);
};
Function.prototype.call.apply(logThisAndArgs, [{'some':'object'},1,2,3,4])
// logs -> Object { some="object"} [1, 2, 3, 4]
Now this!
Function.prototype.call.call(logThisAndArgs, {'some':'object'},1,2,3,4)
// logs -> Object { some="object"} [1, 2, 3, 4]
Less of a wtf and more of a gotcha. In ExpressJS. you can serve static files from a /public directory with this simple directive in your configure block:
configure(function() {
set("root", __dirname);
// allow static file serving from public directory
use(Static);
});
But be careful! This sets a the path to be /public/app.css rather than /app.css. More background here.