Skip to content

Move the var declaration outside the loop #8

Description

@itozyun

JSX で Array#forEach が5倍以上速くなった話

ただ Safari だと for ループの中に var 宣言を入れると遅くなるので、さらに言うなら

var a = [ 1, 2, 3, 4, 5, 6, 7, 8 ];
var sum = 0;
var i, aLen;
for (i = 0, aLen = a.length; i < aLen; ++i) {
  sum += a[i];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions