3 Star 6 Fork 1

tutu/ESC6

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
对象.html 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
tutu 提交于 2018-09-11 17:40 +08:00 . first ES6
<!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>Document</title>
</head>
<body>
<script>
// class Person{
// constructor(name,age){
// this.name=name;
// this.age=age;
// }
// showName(){
// return this.name;
// }
// showAge(){
// return this.age;
// }
// }
// 之前
// var Person={
// name:'abc',
// age:18,
// showAge:function(){
// alert(this.age)
// },
// showName:function(){
// alert(this.name)
// }
// }
// Person.showAge();//18
// 改成:
// var Person={
// name:'abc',
// age:18,
// showAge:()=>{
// console.log(this)
// alert(this.age)
// },
// showName:()=>{
// alert(this.name)
// }
// }
// Person.showAge();
var age=101;
var name='abc'
var Person={
name,
age,
showAge:()=>{ //也可写成showAge(){}
// alert(this.age)
return this.age
},
showName:()=>{
// alert(this.name)
return this.name
}
}
// Person.showAge();
alert(Person.showName())
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/huangjuntu/ESC6.git
git@gitee.com:huangjuntu/ESC6.git
huangjuntu
ESC6
ESC6
master

搜索帮助