Search code examples
jqueryyui3

Deep Cloning in Yui3


How does one deep clone an object in YUI3 ? In jquery it would be typically done as follows

var clone = jQuery.extend(true, {}, object);

Solution

  • Use the clone method provided by the oop module.

    YUI().use("oop", function (Y) {
            var obj = { foo: ["bar", "baz", "biz"] },
            clone = Y.clone(obj, true);
        });