Skip to content

jQuery( null/undefined ) behavior? #1136

Closed
@biziclop

Description

@biziclop

Hi, I read the documentation for jQuery() at https://api.jquery.com/jQuery/ but I haven't found the official behavior for passing a single null or undefined value (or maybe other falsy values too, like false, 0, '') to jQuery().

Currently null and undefined (and other falsies) return an empty set, which is the behavior I would prefer, but I can't know from the docs if I can depend on it.

It's simpler to write $( elementOrNull ) than elementOrNull ? $( elementOrNull ) : $() or $( elementOrNull || []).

Thanks!

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