1 Star 0 Fork 84

旋风小萝莉/前端77

forked from 万少/前端77 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
08-对象简写.html 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
万少 提交于 2022-05-13 11:57 . 对象简写-方法
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0,maximum-scale=1,minimum-scale=1,user-scalable=no"
/>
<title>08-对象简写.html</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
</style>
</head>
<body>
<!--
对象的时候 简洁的写法而已
-->
<script>
// const username = '悟空';
// const skill = '72';
// // const obj = {
// // username: username,
// // skill: skill,
// // };
// // 如果 变量的名称 和 属性的名称 一致的话 ,可以写成下列方式
// const obj = {
// username, // => username : username
// skill, // skill:skill
// // height // => height : height
// };
// console.log(obj);
// const obj={
// username:"悟空",
// // say:function(){
// // console.log("这个是方法 函数");
// // }
// // 简写
// say(){
// console.log("这个是方法 函数");
// }
// }
// obj.say();
const username="悟空";
const obj={
username,
say(){
console.log("方法");
}
}
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/idolHTT/front-end-77.git
git@gitee.com:idolHTT/front-end-77.git
idolHTT
front-end-77
前端77
js高级第1天

搜索帮助