ES6 对象的简写方式
对象内的属性:若对象内的属性和外部变量相同,并且也是使用外部变量的值,那在定义对象的属性的时候,直接写变量名即可,省略值
对象内的函数:函数名(){...};
代码示例:
<html ng-app='app' ng-controller='main' >
<head>
<meta charset="utf-8">
<meta name='viewport' content='width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0'>
<script src='jq/jquery-3.4.1.js'></script>
<style>
</style>
</head>
<body >
<script>
let address='there';
let name='jeff';
let age=18;
let obj={name,
age,
address,
getName(){ return this.name}
};
console.log(obj);
console.log(obj.getName());
</script>
</body>
</html>