KBD

Keith Devens .com

Wednesday, October 15, 2008 Flag waving
REMEMBERS- HEEL BARES DURID! BARE DURIDS IS STORNG FREND! – Alamo

Archive: June 07, 2007

← June 06, 2007June 08, 2007 →

Daily link icon Thursday, June 7, 2007

  1. Because I'm sure it'll come in handy later, here's a javascript object clone function:

    function clone(obj){
        if(obj == null || typeof(obj) != 'object')
            return obj;

        var temp = {};
        for(var key in obj)
            temp[key] = clone(obj[key]);
        return temp;
    }

    Update: From feedback in the comments, a better version is:

    function clone(obj){
        if(obj == null || typeof(obj) != 'object')
            return obj;

        var temp = new obj.constructor(); // changed (twice)
        for(var key in obj)
            temp[key] = clone(obj[key]);

        return temp;
    }
       (19) Tags: [Code, Javascript]
← June 06, 2007June 08, 2007 →
October 2008
SunMonTueWedThuFriSat
 1234
567891011
12131415161718
19202122232425
262728293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 4 posts

Recent comments XML

new⇒Girls, please don't get breast implants

you people implants are fine these​days but they are like body organs​not e...

kym: Oct 15, 5:25pm

Spider solitaire

I have now won, at the "Difficult"​level, 186 games of Spider​Solitaire.  I...

75.179.28.113: Oct 13, 9:34am

I hate PHP

Elliot Anderson,

Dude!! You the​man! The reverse replacement for​array_u...

Alex Ndungu: Oct 11, 1:35am

Generated in about 0.048s.

(Used 7 db queries)

mobile phone