Add double quotes in string in typescript
To add double quotes in the string in typescript, use double quotes both side with the +
operator it will concatenate the string and return a new string with double quotes like below example.
1let str: string = "infinitbility";23// add double quotes4str = '"' + str + '"';5console.log(str) // ๐๏ธ '"infinitbility"'
Add double quotes at the beginning of string in typescript
To add double quotes at the beginning of string in typescript, use double quotes at starting of the string with the +
operator it will concatenate the string and return a new string with double quotes like below example.
1let str: string = "infinitbility";23// add double quotes4str = '"' + str;5console.log(str) // ๐๏ธ '"infinitbility'
To show space at the beginning of the string you should put a double quotes string before the +
operator, like in the above example.
Add double quotes at the end of the string in typescript
To add double quotes at the end of string in typescript, use the +
operator with a double quotes string it will concatenate the string and return a new string with space.
1let str: string = "infinitbility";23// add double quotes4str = str + '"';5console.log(str) // ๐๏ธ 'infinitbility"'
To show add double quotes at the end of string you should put a double quotes string after the +
operator, like in the above example.
I hope it helps you, All the best ๐.
Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.