Skip to content

Instantly share code, notes, and snippets.

View fshost's full-sized avatar

Nathan Cartwright fshost

View GitHub Profile
@fshost
fshost / extend.js
Created November 26, 2012 07:16
javascript deep extend function with support for circular references
// extend one object with another object's property's (default is deep extend)
// this works with circular references and is faster than other deep extend methods
// http://jsperf.com/comparing-custom-deep-extend-to-jquery-deep-extend/2
function extend(target, source, shallow) {
var array = '[object Array]',
object = '[object Object]',
targetMeta, sourceMeta,
setMeta = function (value) {
var meta,
jclass = {}.toString.call(value);