1) How to reverse a string using reduce method?
const rev = str => [...str].reduce((carry, char) => char.concat(carry), '')
Specifically, [...str] is superior to str.split('') because it correctly handles Unicode:
[...str]
str.split('')
'😎'.split('') // ["�", "�"] [...'😎'] // ["😎"]
2) What is the difference between slice and splice?
slice copies a range out of an array. splice deletes and/or inserts items at a given position in an array.
slice
splice
3) How to convert an object into a string?
The question's a little to broad imo, I'm gonna spare the time writing out exactly what Avalander did.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Specifically,
[...str]
is superior tostr.split('')
because it correctly handles Unicode:slice
copies a range out of an array.splice
deletes and/or inserts items at a given position in an array.The question's a little to broad imo, I'm gonna spare the time writing out exactly what Avalander did.