Skip to content

"Clever Conditionals" in Performance is wrong #258

Closed
@ithcy

Description

@ithcy

http://learn.jquery.com/performance/clever-conditionals/

jsperf: http://jsperf.com/jquery-clever-conditionals

The "better" way (using a regex) is 94% slower than the "old way" (simple equality comparison), and I would argue that it's also much less obviously understandable when skimming over code.

The object literal lookup method is also 78% slower than the "old way", but it's not implied that it's "better". I'm not sure what the point is of this example as it's almost as slow and hard to read as the "better" way.

Also, the "old way" should probably use the triple-equals for comparison.

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