JavaScript is required to use Bungie.net

Service Alert
We are actively investigating issues impacting players' ability to sign in to all Destiny releases on Xbox Platforms. Until resolved, players may experience disconnects or be unable to sign in. Please stay tuned to @BungieHelp for updates.

OffTopic

Surf a Flood of random discussion.
Edited by dazarobbo: 1/29/2013 6:44:42 AM
6

Retrieve function body as string

[quote]Object.defineProperty(Function.prototype, "Source", { get: function(){ return /{([\s\S]+)}/.exec(this.toString())[1]; } });[/quote]Magic. I seem to have posted this in the wrong place...

Posting in language:

 

Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

View Entire Topic
  • Edited by Avants Garde: 1/29/2013 11:51:08 PM
    I like to use the normal naming convention, starting with lowercase. Also, 'this' works, but I guess for clarity, toString is okay too. I hate floating regexes like that, so I would rather do this altogether: [quote]this.toString().match(/{([\s\S]+)}/)[1];[/quote]

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

    1 Reply
    You are not allowed to view this content.
    ;
    preload icon
    preload icon
    preload icon