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

NEW
Unassigned

Status

()

Core
JavaScript Engine
5 years ago
4 years ago

People

(Reporter: David Bruant, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

5 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)

Updated

4 years ago
Assignee: general → nobody
You need to log in before you can comment on or make changes to this bug.