Skip to content

Destructuring array will error if no match #130

@Hainesy

Description

@Hainesy

const [, city, zipCode] = address.match(cityZipCodeRegex);

This will error if the address doesn't match, but can be fixed with:

const [, city, zipCode] = address.match(cityZipCodeRegex) || [];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions