Don't allocate an object when doing if(Object(x) === x)

NEW
Unassigned

Status

()

6 years ago
5 years ago

People

(Reporter: bruant.d, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

6 years ago
|if(Object(x) === x)| is recurrent boilerplate used to know whether a value is an object (because typeof is broken). Per spec, it's supposed to allocate an object if x isn't one (and return x if it is), so this particular pattern doesn't need the extra allocation of an object which will not be used (except for its identity)
Assignee: general → nobody
You need to log in before you can comment on or make changes to this bug.