String Usage in JavaScript

What are the correct ways to work with strings in JavaScript?

I recommend using double quotes to delimit strings even though single quotes are also permitted. In addition, avoid multi-line strings. Instead, split long strings into multiple ones and concatenate them. See the examples below.


// Not good.
let aVeryLongString = "Oh, supercalifragilisticexpialidocious! Even though the sound of it \ 
Is something quite atrocious.";

// Good.
let aVeryLongString = "Oh, supercalifragilisticexpialidocious! " + 
                      "Even though the sound of it" + 
                      "Is something quite atrocious.";

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s