Can Strings be Objects?

Hello there,
can string be object used in calling a method?
e.g,
‘hello’.toUpperCase();

What language are you asking this about? If it’s javascript you can use toUpperCase() indeed. Note that this doesn’t actually change or store the string, for that you’d have to save it to a variable.

> str = "hello";
'hello'
> str.toUpperCase();
'HELLO'
> 'whynot'.toUpperCase();
'WHYNOT'

In python?

In haskell?

Prelude Data.Char> capitalize = map toUpper
Prelude Data.Char> capitalize "this is getting awfully weird"
"THIS IS GETTING AWFULLY WEIRD"
1 Like

i am asking about JS language

Did the first reply answer your question? Or did you mean to ask about something else?

it actually did thank you

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.