Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use String#includes to see if a substring exists instead of indexOf #336

Open
andria-dev opened this issue Dec 31, 2019 · 0 comments
Open

Comments

@andria-dev
Copy link

In live-server.js I noticed that you're using String#indexOf to see if an item exists in an array as opposed to the more appropriate String#includes. I doubt there's enough of a performance difference to truly matter but it's much more readable.

It also is slightly less characters overall to use .includes() than .indexOf() > -1

For example:

/* OLD */
if (arg.indexOf("--port=") > -1) {
}

/* NEW */
if (arg.includes("--port=")) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant