当前位置:网站首页>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 ");
}
}
边栏推荐
- 实例搭建Flask服务(简易版)
- Notes on letter symbol marking of papers
- tron OUT_ OF_ ENERGY
- 座机的表单验证
- 深入C语言(4)——switch的定义与使用
- Build redis environment under windows and Linux
- (codeforce547)C-Mike and Foam(质因子+容斥原理)
- Functions and comparison of repeaters, hubs, bridges, switches and routers
- Understanding of p-type problems, NP problems, NPC problems, and NP hard problems in natural computing
- The difference between int and integer. Is int or integer used in practical applications?
猜你喜欢
Process tracking of ribbon principle
小马智行进军前装量产,从自研域控制器入手?
The digitalization of the consumer industry is upgraded to "rigid demand", and weiit's new retail SaaS empowers enterprises!
KNN method predicts pregnancy, KNN principle simple code
Sleuth+Zipkin 来进行分布式服务链路的追踪
Deep into C language (1) -- operators and expressions
Machine learning [numpy]
Deep understanding of Base64 underlying principles
RHCE's at, crontab's basic operations, the Chrony service, symmetric encryption and asymmetric encryption
Android view system and custom view Series 1: (kotlin version)
随机推荐
SFTP upload error: com.jcraft.jsch JSchException: connection is closed by foreign host
如何判定是stun协议
(2022 Hangdian multi school III) 1011 link is as bear (thinking + linear basis)
小马智行进军前装量产,从自研域控制器入手?
1985-2020(8个版次)全球地表覆盖下载与介绍
Simple use of eventbus
1. Header file - Comment - namespace - standard input / output stream
Environment configuration stepping pit during colab use
RHCE's at, crontab's basic operations, the Chrony service, symmetric encryption and asymmetric encryption
(nowcoder22529C)dinner(容斥原理+排列组合)
Numpy acceleration -- > cupy installation
路西法98-生活记录ing
Code ~ hide or disable the status bar and virtual keys
How fast does it take to implement a super simple language
"The programming is not standardized, and my colleagues are in tears!"
Kotlin companion object vs global function
Beijing post network research 2015 problem2
Why does the 20 bit address bus determine the storage space of 1MB
How do programmers use code to completely end those things in the system?
Why BGP server is used in sunflower remote control? Automatic optimal route and high-speed transmission across operators