Show HN: Fully-featured Nil interpreter in less than 1 line of JavaScript
ajf.me
ajf.me
Now, if you could override Function.prototype to just function(){}, then everything passed in would be ignored and you'd have a proper Nil interpreter in JS. But you can't[1], because that would be stupid.
[1] Or rather, I can't. I did just spend a few minutes trying.
Function.prototype.apply = Function.prototype.call = function () {};
Insert this subtly somewhere into other people's code to ruin their day/weekFunction.prototype is already set to an empty function by default (evaluate Function.prototype() and you get 'undefined'), so I am not sure this has the consequences you think it does.
When you call a function object, let's say f, Javascript looks for an internal method on f called [[Call]] and calls it. If one doesn't exist, an error is thrown. The internal property [[Prototype]] of f is not ever considered, although you are right that it would be equal to Function.prototype.
EDIT: Despite what I think, executing phpnode's code in my node.js REPL instantly crashes it, so I guess there is more going on here.
[1] https://groups.google.com/forum/#!topic/nodejs/FuOB3151rPQ
Is an empty string less than one line of code? Or is it one line of zero length?
I wandered lonely as a cloud.
Outputs:Otherwise wonderful work. I think it would be difficult to top this.
https://news.ycombinator.com/item?id=6759980
Still not very classy, is it?
The submitted page actually well predates this "30 lines" fad, I just realised it might be an effective parody today. The joke works better in HTML form, as it takes longer to see it.
(should be an empty file)
No?
<script type="text/javascript"></script> <script type="text/javascript"/>
Not quite valid HTML, but it's semantically very valid indeed.