Skip to content

Feature detection does not respect return statements #523

@rvock

Description

@rvock

I like to use early return statements in functions, if a feature is unsupported. This leads to incorrect warnings:

function version1() {
	if (window.fetch === undefined) {
		return;
	}

	// triggers a warning
	window.fetch();
}

function version2() {
	if (window.fetch !== undefined) {
		// triggers no warning
		window.fetch();
	}
}

I prefer version1 because the remaining code within the function does not need to be indented and thus is easier to read/understand.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions