There are many great improvements provided by ES6 (introduced in Y2015), but I think a couple of them are really cool.
String includes
includes
checks whether a certain (sub) string exists in the provided string. Note that this operation is case sensitive.
|
|
Not quite complicated, but makes the language that much more friendly :)
Earlier, we used a very complicated piece of code to achieve the same result.
|
|
The same works for arrays as well.
|
|
String startsWith
and endsWith
If you totally dig includes
, but wanted that extra zing to find start or end variables - ES6 has you covered.
|
|
String match
Regular expressions are a must if you have more complex requirements for a string search. We can do that in Javascript with just the string variable.
|
|
String repeat
How about repeating a string x
number of times? Yes, totally possible.
|
|