js数组遍历之~forEach

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/themagickeyjianan/article/details/87693358
cards.forEach(function (value, index, arr) {
            var comp = self.getPoolCard().getComponent("Card")
            comp.init(value);
            comp.setIndex(-1);
            comp.small();
            comp.node.x = (index * 30);
            comp.node.y = 0;
            self.nodOuts.addChild(comp.node);
        });

value就是在index处,对应的数组该索引处的值。

猜你喜欢

转载自blog.csdn.net/themagickeyjianan/article/details/87693358