Is there an efficient way to clone an object yet leave out specified properties? Ideally without rewriting the $.extend function?
var object = {
"foo": "bar"
, "bim": Array [1000]
};
// extend the object except for the bim property
var clone = $.extend({}, object, "bim");
// = { "foo":"bar" }
My goal is to save resources by not copying something I’m not going to use.
jQuery.extendtakes an infinite number of arguments, so it’s not possible to rewrite it to fit your requested format, without breaking functionality.You can, however, easily remove the property after extending, using the
deleteoperator: