当前位置:网站首页>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 ");
}
}
边栏推荐
- Beijing post network research 2015 problem2
- Notes on letter symbol marking of papers
- Spark dataframe replaces empty characters (or other values) in each column with null
- 消费行业数字化升级成 “刚需”,weiit 新零售 SaaS 为企业赋能!
- 一文学透MySQL表的创建和约束
- Remote desktop connection error
- (2022 Hangdian multi school III) 1002 boss rush (pressure dp+ dichotomy)
- What you see and think in Microsoft
- Flutter 启动白屏
- Why do many programmers hate pair programming?
猜你喜欢
随机推荐
Build redis environment under windows and Linux
Common methods of lodash Library
Why is continuous integration and deployment important in development?
(2022 Hangdian multi school III) 1011 link is as bear (thinking + linear basis)
(codeforce547) c-mike and foam
Vs code must know and know 20 shortcut keys!
Target detection, industrial defects, image segmentation -- deep learning data set induction
Practical application cases of digital Twins - smart energy
Realize multi-level linkage through recursion
一文学透MySQL表的创建和约束
路西法98-生活记录ing
Form verification of landline
What have I learned from 200 machine learning tools?
Why do programmers so "dislike" the trunk development mode?
Instance setup flask service (simple version)
Cloudera manager platform fault repair record
Numpy acceleration -- > cupy installation
Code speed optimization
Uni app internationalization
Several cases of word wrapping in div









