Skip to content

Lack of Error Thrown when Using 'in' Operator on Non-Objects #2427

Open
@marccarigiet

Description

  • Plattform: [Linux, Ubuntu 20.04]

Description
'in' applied to non-objects do not throw an error.

Test case
Test code to reproduce the behaviour:

'example' in true;
'example' in false;
'example' in undefined;
'example' in null;
'example' in this;
 
'example' in 'example';
'example' in 1;

Expected behaviour
Going by other JavaScript engines including V8, SpiderMonkey and JavaScriptCore I'd expect a TypeError to be thrown.

Additional context
This was found using comparative testing between multiple JavaScript engines. This could very much come down to a design choice. I just wanted to let you know in case it is not intentional

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