Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String concatenation in TypeScript [closed]

Tags:

typescript

I am having difficulties concatenating strings in TypeScript.

Code:

var info= {user:'med'};
console.log('le nom est:${info.user}');

The result is:

le nom est:${info.user}

How do I concatenate 2 strings in TypeScript?

like image 838
devit2017 Avatar asked Aug 02 '17 09:08

devit2017


People also ask

How do you concatenate strings in TypeScript?

The concat() is an inbuilt function in TypeScript which is used to add two or more strings and returns a new single string. Syntax: string. concat(string2, string3[, ..., stringN]);

What is string [] in TypeScript?

In TypeScript, the string is sequence of char values and also considered as an object. It is a type of primitive data type that is used to store text data. The string values are used between single quotation marks or double quotation marks, and also array of characters works same as a string.

How do you concatenate two numbers in TypeScript?

To concatenate two numbers in JavaScript, add an empty string to the numbers, e.g. "" + 1 + 2 . When using the addition operator with a string and a number, it concatenates the values and returns the result. Copied! We used the addition (+) operator to concat two numbers.


1 Answers

With a template string:

console.log(`The name is: ${info.user}`);
like image 186
Paleo Avatar answered Oct 22 '22 06:10

Paleo