0

In many languages like C or Java, the string is non-primitive data type and it is just array of chars, but in js according to mdn:

https://developer.mozilla.org/en-US/docs/Glossary/Primitive

The string is primitive data type that because it is not an object, unlike the array which is objects.

So if string not an array of chars, so what it is and why can it take properties like array such as .length?

Amir Makram
  • 12,030
  • 3
  • 13
  • 25
  • even primitive data types have `toString` property. some may have more properties. – Nina Scholz Oct 20 '19 at 07:55
  • The C or Java implementation of thinking of strings as `char[]` is pretty irrelevant. Don't apply it to Javascript. In Javascript a string is a string, period. There's still an interesting thing about "primitives" and "objects", which is answered in the duplicate. – deceze Oct 20 '19 at 07:59

0 Answers0