Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I like using toString to convince the console to omit parentheses. Another way would be to use getters, like so:

    window.__defineGetter__('help', function () {
        console.log('I\'m here for you');
    });


interesting, I didn't know about that. You still end up having to do a toString override to properly suppress the 'undefined' return value though:

    window.__defineGetter__('help', function () {
        console.log('I\'m here for you'); f = function() {}; f.toString = function() {return " ";}; return f;
    });
But __defineGetter__ would let the execution of the command work in other places than the JS console, so that's cool.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: