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

需要使用Array.isArray(obj)来判断变量是否为数组 #12

Open
tiaod opened this issue Dec 7, 2016 · 1 comment
Open

需要使用Array.isArray(obj)来判断变量是否为数组 #12

tiaod opened this issue Dec 7, 2016 · 1 comment

Comments

@tiaod
Copy link

tiaod commented Dec 7, 2016

C3D.create = function (obj) {
        var _obj;
        switch (typeof(obj)) {
            case 'array':
                _obj = {type: 'sprite', children: obj};
                break;
            case 'object':
                _obj = obj;
                break;
            default:
                return;
        }

        return createObj(_obj);
    };

这段代码里面使用了typeof(obj)来判断是否为数组。事实上typeof([])返回的是'object'

@shrekshrek
Copy link
Owner

多谢提醒,已修复

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

2 participants