TypeScript series type string

Memories of sentences


background

Unlike JavaScript, TypeScript uses static typing, which means it specifies the data type that a variable can hold. As shown in the following code, if you specify the data type that a variable can save in JavaScript, an error will be reported:类型注释只能在 TypeScript 文件中使用。ts(8010)

let str: string = "a";

TypeScript is a superset of JavaScript. TypeScript needs to be compiled (grammar conversion) to generate JavaScript before it can be executed by the browser.

In TypeScript, string is the basic string type and stores UTF-16 string series. Use single quotes ('') or double quotes ("") to contain strings.

let name: string = "TypeScript";

You can also use backticks (``) to format text or inline expressions

let words: string = `您好,今年是${
      
      name}发布${
      
      years + 1}周年`;

write at the end

If you feel that the article is not very good //(ㄒoㄒ)//, just leave a message in the comments and the author will continue to improve it; o_O???
if you think the article is a little useful, you can give the author a like; \\*^o^*//
if you want to make progress with the author, you can scan the QR code on WeChat , pay attention to the front-end old L ; ~~~///(^v^)\\\~~~
thank you readers (^_^)∠※! ! !

Guess you like

Origin blog.csdn.net/weixin_62277266/article/details/133102171