ES6 除了新增了上篇的let & const之外,也提供了新的模版字符串(Template Literal)用法:
范例一:
过去写法(ES5): 过去我们习惯使用 "+" 来做字串的相加。
let example_es5 = '<div>\n'+
'<div class="container">\n'+
'<img src="example_pic.jpg"\n'+
'</div>\n'+
'</div>'
现在写法(ES6): 模板字串支援换行符号,就不需使用\n表示换行。
let example_es6 = `
<div>
<div class='container'>
<img src="example_pic.jpg>
</div>
</div>`
范例二
过去写法(ES5): 过去我们也习惯使用 "+" 来做变数的相加。
let a = 'Lisa';
let b = '20';
let c = 'My name is ' + a + ', I am ' + b + ' years old.';
现在写法(ES6): 在模板字串下,可以透过${ }的方式放入变数。
let a = 'Lisa';
let b = '20';
let c = `My name is ${a}, I am ${b} years old.`;
当我们网页建立了基本的authentcation,接着就能开始建立我们的功能,首先在web上的htm...
binary search tree中,本来遵守着从中间Node切开,左边小於右边的规则,但是现在有...
上一篇介绍 firestore CRUD 的各种方式,今天要来介绍进阶的查询资料方式,利用条件去过滤...
前情提要 方函式准备展示第二个型态 我:有些情境下,时间就是不能掌握,这要求也太夸张了。 方函式:很...
Lens - K8s上好用的client端程序 除了使用kubectl cli去操作k8s外,也有u...