Expression of class
Strict mode:
- In the <script> in the first line write "use strict", indicates that the following code uses strict mode (or the first line in the file js)
- Use custom code, using more standardized, run to avoid some strange behavior
- Es subsequent Angular Some other characteristics and JS framework, it is required to be run in strict mode
- Make more efficient to compile and run the code of
impact variables - Variable must first declare reuse
- You can not use any reserved words / keywords as variable names
- Strict mode will not allow users to delete variables (delete)
important point:
- In ES6, the default is the strict mode, there is no need to use "use strict" to specify the mode of operation
- There is no variable lift
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>表达式</title>
</head>
<body>
<script>
{
//属性表达式
let shopping = "shop";
class Person{
constructor(sex) {
this.sex = sex;
this.hobby = "女";
}
[shopping](){
console.log("一个省钱的春节");
}
}
let person = new Person();
person.shop();
}
{
// Class 表达式
const MyClass = class Me {
}
}
</script>
</body>
</html>