Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objectにもcloneを! #118

Open
omatoro opened this issue Jun 10, 2014 · 0 comments
Open

Objectにもcloneを! #118

omatoro opened this issue Jun 10, 2014 · 0 comments

Comments

@omatoro
Copy link
Contributor

omatoro commented Jun 10, 2014

Arrayのdeep copyにて、内部にObjectが存在するとnarrow copyとなってしまいます。
原因は、Objectにはcloneが無いからだと思われます。

    Array.defineInstanceMethod("clone", function(deep) {
        if (deep == true) {
            var a = Array(this.length);
            for (var i=0,len=this.length; i<len; ++i) {
                a[i] = (this[i].clone) ? this[i].clone(deep) : this[i];
            }
            return a;
        };

        return Array.prototype.slice.apply(this);
    });

是非対応お願いします!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant