4 ways to combine strings in JavaScript

A thread ⤵️

#100DaysOfCode #CodeNewbies
1. Using concatenation operator ( + )

You can use the + operator in many ways such as to add numbers, convert strings into numbers, and also to concatenate two or more strings.

Note: We need to add the space explicitly. You can also use the += operator to add strings. Image
2. Using string concat() method

string.concat() method takes one or more strings as arguments and returns a new string.

Syntax
→ string.concat(string1, string2, ..., stringN)

Note: It doesn't change the existing string. Image
3. Using template string

Template strings are much simpler and more readable.

Template strings start and end with backticks ( ` ). To add string you use ${<any expression>}.

The expression inside ${} will be evaluated first and then concatenated with the string. Image
4. Using array join() method
the join() method returns the array elements as a string.

join() method takes a separator as an optional argument which is used to separate the array elements. Default is comma ( , ) Image
Thank you for taking the time to read this thread. 💛

If you enjoyed this thread →

1. Consider retweeting the thread's first tweet.
2. Follow me on Twitter ( @junaidshaikh_js ) for more related content.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Junaid ⚡

Junaid ⚡ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @junaidshaikh_js

14 Aug
13 Websites that will help you improve your frontend skills by building real-world projects. 💪

A thread ⤵️
1️⃣ Frontend Mentor { @frontendmentor }

🔗 frontendmentor.io
2️⃣ 100 Days of CSS

🔗 100dayscss.com
Read 15 tweets
13 Aug
Learn 3 useful Python functions that will help you in understanding your program and debugging it.

A thread ⤵️

#100DaysOfCode #CodeNewbie
1️⃣ type()

You know that Python is a dynamically typed programming language. That means you don't specify the type of variable while declaring it but it depends on the value it holds.

If you don't know what type of value a variable holds, pass it to the type() function. Image
2️⃣ dir()

Okay, you know how to check the type of variable. in the above code, the variable 'name' is of type 'str' stands for 'string'.

Now, you can pass this type of object into the dir() function to get all the availbe methods on that particular object.

Pretty useful, right? Image
Read 5 tweets
3 Aug
CSS Shorthand Properties.

Learn 12 CSS shorthand properties and save your time by writing less code.

A thread ⤵️

#100DaysOfCode #CodeNewbie
1. background

Shorthand for -

→ background-color

→ background-image

→ background-position

→ background-size

→ background-repeat

→ background-origin

→ background-clip

→ background-attachment
2. border

Shorthand for -

→ border-width

→ border-style

→ border-color
Read 15 tweets
31 Jul
HTML <input> Types

Do you know?
There are almost 22 types of input fields 🤯
Let's see how many of them you know.

A thread ⤵️

#100DaysOfCode #CodeNewbie
🔸 Input type text

The most common type of input used is of type text. It defines a single-line text input field.

<input type="text">
🔸Input type submit

This type is rendered as the button. When the user clicks on this (click event) the form is submitted to the server.

<input type="submit">
Read 24 tweets
30 Jul
FREE UDEMY COURSES 🔥🔥

3 FREE Udemy courses you can do this weekend.

Topics: Python, Public Speaking, DevOps

Note: Courses may be available for few hours. Grab them as soon as possible.

#100DaysOfCode #CodeNewbie
➡️ Python 3 Master Course for 2021

Rating: 4.1⭐️

🔗udemy.com/course/python-…
➡️ First Step into Public Speaking

Rating: 4.3⭐️

🔗 udemy.com/course/first-s…
Read 5 tweets
16 Jul
10 VS Code extensions that will help you to be more productive 💪

A thread...

#100DaysOfCode #CodeNewbie #vscode #webdevelopment
1. Prettier

Prettier is the code formatter extension. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.

🔗marketplace.visualstudio.com/items?itemName…

#100DaysOfCode #CodeNewbie
2. Simple React Snippets

If you are a React developer, check out this extension that provides an essential collection of React Snippets and commands

🔗marketplace.visualstudio.com/items?itemName…

#100DaysOfCode #CodeNewbie #vscode #webdevelopment
Read 12 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(