live-server
live-server copied to clipboard
Use String#includes to see if a substring exists instead of indexOf
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=")) {
}