TS Getting Started

A string:

1, multi-line string double apostrophe wrap

`hello
hello`

 

2, String template (reference variable).

 var a = 5
console.log(`${a}`);

3, automatically split string (Test method calls the template, the template is automatically split into a first character Template variable, the expression of the entire template will be split into an array, and the array as arguments pass the method used for the received parameter.

function test(template,name,age){
console.log(template);
console.log(name);
console.log(age);

}
var name = 'chen';
var getAge=function(){
return 18;
}
test`hello my name is ${name},i am ${getAge()}`,

 

Guess you like

Origin www.cnblogs.com/Glant/p/11909807.html