Modern JavaScript for React: Template Strings – Part 5

Template Strings is one of the most useful features introduced in modern Javascript. We have learned Destructuring Object and Arrays in previous posts. Now, let’s go through this.

Modern JavaScript for React: Template Strings



You can define strings in javascript using single quotes (‘ ‘) or double-quotes (” “). These two ways to define strings in Javascript are equivalent.

Modern ways to define strings, and that’s using the Backtick () character. You have to train your eyes a little bit to spot those.

Strings defined in Backtick character are called as Template strings because they can use as a template with dynamics values.

They support what we call interpolation.

You can Inject any dynamic expression in Javascript within dollar curly brackets.

Example of Template String

You can see in the below code we have used div template inside Backtick and inside dollar curly bracket we have defined Math.random function.

See the output here in the console window.

We hope you got an idea about this. In the upcoming article, we will deep dive in the Classes in the modern Javascript.

Tutorial Funda

Tutorial Funda will keep you updated with the latest Programming Languages, Software Tools and related technologies used in Software Development.

Leave a Reply

Your email address will not be published. Required fields are marked *