当前位置:网站首页>String template of ES6 new features and methods to simplify objects and functions
String template of ES6 new features and methods to simplify objects and functions
2022-07-29 03:45:00 【Haha, APE】
Template string (template string) It's an enhanced string , Use back quotes (``) identification
characteristic :
1. String templates can store line breaks
2. have access to ${xxx} Formal reference variable
// Statement
let string = ` I am also a string `
console.log(string);
// Print the results : I am also a string
Line breaks can appear in string templates
// characteristic
// Line breaks can appear in string templates
let str = ` <ul> <li> Xiao Liu </li> <li> Xiao Zhang </li> <li> Hunan changsha </li> <li> Wuhan, Hubei </li> </ul> `
console.log(str);
// <ul>
// <li> Xiao Liu </li>
// <li> Xiao Zhang </li>
// <li> Hunan changsha </li>
// <li> Wuhan, Hubei </li>
// </ul>
have access to ${xxx} Formal reference variable
let Girl = " Xiao Liu "
let beautifulGirl = `${
Girl} It's a beautiful girl `
console.log(beautifulGirl);
// Print the results : Xiao Liu is a beautiful girl
Methods to simplify objects and functions
ES6 It is allowed to write variables and functions directly within the braces of the object as the properties and methods of the object
let name = " Xiao Liu "
let change = function(){
console.log(" Change yourself, change the world ");
}
// Creating objects
const information = {
// Complete writing
// name:name,
// change:change
// es6 Simplify writing
name,
change,
// Declaration method simplification
say(){
console.log(" Xiao Liu is a lovely classmate ");
}
}
边栏推荐
- In depth C language (4) -- definition and use of switch
- EMD 经验模态分解
- 2. Variables and scope
- (codeforce547)C-Mike and Foam(质因子+容斥原理)
- Android view system and custom view Series 1: (kotlin version)
- CUB_ Visualization of key points in 200 bird dataset
- How do programmers use code to completely end those things in the system?
- Practical application cases of digital Twins - smart energy
- Violence recursion to dynamic programming 01 (robot movement)
- Instance setup flask service (simple version)
猜你喜欢

Shopify seller: EDM marketing should be combined with salesmartly to easily get the conversion rate

Realize multi-level linkage through recursion

Ribbon principle analysis namedcontextfactory

Shutter start white screen

Sleuth+zipkin to track distributed service links

Typescript from getting started to mastering (XVI) configuration file - first knowledge of compileroptions configuration item

Sunflower senior product director technology sharing: "how to apply national remote control" in AD domain environment

实例搭建Flask服务(简易版)

(2022杭电多校三)1002-Boss Rush(状压DP+二分)

Since 2019, you must have stopped using this marketing strategy
随机推荐
SFTP upload error: com.jcraft.jsch JSchException: connection is closed by foreign host
Easy to use remote sensing data set download website~~~
Flutter 启动白屏
"Strangers once met" Summer Street Shen Shuyan_ Xia Mo Shen Shuyan's latest chapter
sql
SQL窗口函数
Cannot paste multiple pictures at once
Alibaba Font Icon Library Usage and update methods
(newcoder 15079) irrelevant (inclusion exclusion principle)
Simple understanding of CDN, SDN and QoS
容斥原理
(2022杭电多校三)1011-Link is as bear(思维+线性基)
for_ Example of each usage
(codeforce547)C-Mike and Foam(质因子+容斥原理)
Various minor problems of jupyter notebook, configuration environment, code completion, remote connection, etc
What have I learned from 200 machine learning tools?
Since 2019, you must have stopped using this marketing strategy
In depth C language (4) -- definition and use of switch
Shopify卖家:EDM营销就要搭配SaleSmartly,轻松搞定转化率
实例搭建Flask服务(简易版)