tapio / live-server

A simple development http server with live reload capability.
http://tapiov.net/live-server/
4.41k stars 484 forks source link

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

Open andria-dev opened 4 years ago

andria-dev commented 4 years ago

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=")) {
}