Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
hacker17726ySame with other iterables such as arrays :)
It's super useful!
https://developer.mozilla.org/en-US... -
It's also nice if you want to manipulate the first char. Only putting the string back together is a bit awkward to me
const [first,...rest] = "Hello World"
return first.toLowerCase() + rest.join('') -
hacker17726y@host127001
Interesting, that's a much cleaner approach than the one I made for capitalizing the first letter of a string:
stringVariable.toLowerCase().replace(/^(.)|\s(.)/g, ($1) => $1.toUpperCase()))
^ That looks pretty ugly hahah
Related Rants
Quick JS tip
If you want to split a string into characters, you can use the ES6 spread operator
If you have
const name = 'react-dev'
You can just spread it like this:
const charsInName = [...name]
random
js
code
snippet