Treating strings as an array of chars, maybe a new Char type?

String's are sort of a collection of Char's, but immutable. So, why not make it more functional and iterative?

Right now, to treat string as an array we have to .split('') and then .join('') back, but what if this would happen more seamlessly?

You can sort of achieve it with this hacky hack:

String.prototype.map = Array.prototype.map

And then if you call

"hello".map((e,i,self) => self[self.length-1-i])

Which will return ['o', 'l', 'l', 'e', 'h'].

This kinda works with methods that don't mutate the string (previously array). But still yeilds some weird behavior.

for(a in str){ console.log(a) } // 0, 1, 2, 3, 4, 5, map, filter

And will not with things that do

String.prototype.reverse = Array.prototype.reverse
"hello".reverse()

Will yield and error saying that "we can assign value to readonly property".

Just imagine how amazing, clean and simple would JS be. Heck, we are going functional way, which is great, why not go all the way.

someString.split('').sort().join('')

will become

someString.sort()

and

someString.split('').reverse().join('')

will become

someString.reverse()

Is this even necessary? Are there any better ideas how to go about this?

You don't have to do the horrifically bad practice of mutating objects you don't own to do that; you can Array.prototype.map.call(string, mapper).join('').

What would be the benefit of a Char type of length 1, especially considering that :poop: has a length of 2, and :rainbow_flag: has a length of 6?

If you're talking about cases where you want to map one string to another one character at a time (but not one code point, or one grapheme cluster at a time); or use cases where you want to reverse a string by character (but not by code point, or by grapheme cluster, or if the text is RTL), then that would be interesting to hear more about.

May be a new Char type?

Basically in JavaScript string is a primitive data type. And a type is primitive only when a data type cannot be further broken in primitive types.
Suppose in Java String are not primitive because they can be broken down to char primitive type (in java we have a dedicated char type), hence String in Java cannot be primitive.

Where as in JavaScript a string is primitive because there is no such thing called char type in JavaScript, even we break down each element we refer to char is still string only. Therefore if we want a new char type in JavaScript then Strings will not be primitive whole idea needs to be changes from a language perspective.