I wouldn't call these "character literals", because characters are a different data type from strings in many languages (character is to string as integer is to array of integers). So a character literal would be a syntactical way of expressing a character, such as C's single quote marks or Elixir's ? notation.
I appreciate your point of view. But if you look at resources such as W3C and even various writings about JavaScript in books such as Professional JavaScript for Web Developers they do mention them as character literals and many times as string literals as well. I do understand where you are coming from and the logic behind what you are saying, but this literal syntax also always you to use unicode characters and print them to strings. It's probably that reason they refer to this as Character Literals!
Can't share the image from the book on this comment but here is a post from stack overflow talking about the same stackoverflow.com/q/28858138/8456836
That's interesting, but I think that's referring to a different concept again. For example, "A" uses a character literal, but "\x41" doesn't (even though they are the same string). So in the case of escaping newlines, "\n" doesn't use a character literal, whereas
Hmm I would agree to that looking at the logic! How about chnaging the title to escape characters and having a genral approach towads it rather than refering to a specific escape charater that generatds charater literals 👍
I wouldn't call these "character literals", because characters are a different data type from strings in many languages (character is to string as integer is to array of integers). So a character literal would be a syntactical way of expressing a character, such as C's single quote marks or Elixir's
?
notation.Changed the title to Escape Sequence 😀😀 ... Thank you it was a good discussion 👍🙏
I appreciate your point of view. But if you look at resources such as W3C and even various writings about JavaScript in books such as Professional JavaScript for Web Developers they do mention them as character literals and many times as string literals as well. I do understand where you are coming from and the logic behind what you are saying, but this literal syntax also always you to use unicode characters and print them to strings. It's probably that reason they refer to this as Character Literals!
Can't share the image from the book on this comment but here is a post from stack overflow talking about the same
stackoverflow.com/q/28858138/8456836
That's interesting, but I think that's referring to a different concept again. For example,
"A"
uses a character literal, but"\x41"
doesn't (even though they are the same string). So in the case of escaping newlines,"\n"
doesn't use a character literal, whereasdoes.
Hmm I would agree to that looking at the logic! How about chnaging the title to escape characters and having a genral approach towads it rather than refering to a specific escape charater that generatds charater literals 👍
Yes, personally I'd call them "escape sequences" (with
\
being the "escape character").Anyway, nice article! 😁
Yes agreed 💯