MySQL
This commit is contained in:
13
code/ES6/src/01_block_bindings/01_var.js
Normal file
13
code/ES6/src/01_block_bindings/01_var.js
Normal file
@ -0,0 +1,13 @@
|
||||
function test(flag) {
|
||||
if (flag) {
|
||||
var value = "blue";
|
||||
console.log(value);
|
||||
} else {
|
||||
console.log(value);
|
||||
}
|
||||
console.log(value);
|
||||
}
|
||||
|
||||
test(true);
|
||||
test(false);
|
||||
|
13
code/ES6/src/01_block_bindings/02_let.js
Normal file
13
code/ES6/src/01_block_bindings/02_let.js
Normal file
@ -0,0 +1,13 @@
|
||||
function test(flag) {
|
||||
if (flag) {
|
||||
let value = "blue";
|
||||
console.log(value);
|
||||
} else {
|
||||
console.log(value); //value在此处不能访问
|
||||
}
|
||||
console.log(value); //value在此处不能访问
|
||||
}
|
||||
|
||||
test(true);
|
||||
test(false);
|
||||
|
@ -0,0 +1,5 @@
|
||||
(function test() {
|
||||
console.log(typeof value); // 引用错误
|
||||
let value = "blue";
|
||||
console.log(value);
|
||||
})();
|
@ -0,0 +1,5 @@
|
||||
console.log(typeof value);
|
||||
(function test() {
|
||||
let value = "blue";
|
||||
console.log(value);
|
||||
})();
|
9
code/ES6/src/01_block_bindings/05_var_for.js
Normal file
9
code/ES6/src/01_block_bindings/05_var_for.js
Normal file
@ -0,0 +1,9 @@
|
||||
let list = [];
|
||||
for (var i = 0; i < 10; i++) {
|
||||
list.push(function () {
|
||||
console.log(i);
|
||||
});
|
||||
}
|
||||
list.forEach(function (func) {
|
||||
func();
|
||||
});
|
9
code/ES6/src/01_block_bindings/06_let_for.js
Normal file
9
code/ES6/src/01_block_bindings/06_let_for.js
Normal file
@ -0,0 +1,9 @@
|
||||
let list = [];
|
||||
for (let i = 0; i < 10; i++) {
|
||||
list.push(function () {
|
||||
console.log(i);
|
||||
});
|
||||
}
|
||||
list.forEach(function (func) {
|
||||
func();
|
||||
});
|
26
code/ES6/src/02_strings_template/01_string_methods.js
Normal file
26
code/ES6/src/02_strings_template/01_string_methods.js
Normal file
@ -0,0 +1,26 @@
|
||||
let msg = "Hello world!";
|
||||
console.log(msg.startsWith("Hello")); // true
|
||||
console.log(msg.endsWith("!")); // true
|
||||
console.log(msg.includes("o")); // true
|
||||
console.log(msg.startsWith("o")); // false
|
||||
console.log(msg.endsWith("world!")); // true
|
||||
console.log(msg.includes("x")); // false
|
||||
console.log(msg.startsWith("o", 4)); // true
|
||||
console.log(msg.endsWith("o", 8)); // true
|
||||
console.log(msg.includes("o", 8)); // false
|
||||
|
||||
console.log("x".repeat(3)); // "xxx"
|
||||
console.log("hello".repeat(2)); // "hellohello"
|
||||
console.log("abc".repeat(4)); // "abcabcabcabc"
|
||||
|
||||
'x'.padStart(5, 'ab'); // 'ababx'
|
||||
'x'.padStart(4, 'ab'); // 'abax'
|
||||
|
||||
'x'.padEnd(5, 'ab'); // 'xabab'
|
||||
'x'.padEnd(4, 'ab'); // 'xaba'
|
||||
'xxx'.padStart(2, 'ab'); // 'xxx'
|
||||
'xxx'.padEnd(2, 'ab'); // 'xxx'
|
||||
|
||||
'abc'.padStart(10, '0123456789'); //'0123456abc'
|
||||
'x'.padStart(4); // ' x'
|
||||
'x'.padEnd(4); // 'x '
|
23
code/ES6/src/02_strings_template/02_template.js
Normal file
23
code/ES6/src/02_strings_template/02_template.js
Normal file
@ -0,0 +1,23 @@
|
||||
// 1.模板字面量
|
||||
let name = "Nicholas",
|
||||
message01 = `Hello, ${name}.`;
|
||||
console.log(message01); // "Hello, Nicholas."
|
||||
|
||||
// 2.支持JS表达式
|
||||
let count = 10,
|
||||
price = 0.25,
|
||||
message02 = `${count} items cost $${(count * price).toFixed(2)}.`;
|
||||
console.log(message02); // "10 items cost $2.50."
|
||||
|
||||
// 3.多行字符串
|
||||
let message03 = `Multiline
|
||||
string`;
|
||||
console.log(message03); // Hello,
|
||||
// string
|
||||
|
||||
// 4.多行字符串与模板嵌套
|
||||
let fullName = "Nicholas",
|
||||
message04 = `Hello,
|
||||
my name is ${fullName}.`;
|
||||
console.log(message04); // Hello,
|
||||
// my name is Nicholas.
|
Reference in New Issue
Block a user