js 函数与类的区别
2024-10-15 12:02:27
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body> </body>
<script> function show() { console.log(this)
} show(); //window object
new show(); //object j = {
name:'ldq',
age:18,
info:function () {
console.log(`我的名字是${name},我的年龄是${age}`)
console.log(123)
}
};
console.log(j);
new j.info(); function show(name,age) {
//系统偷偷替我们做了
// var this = new object(); this.name = name;
this.age = age;
this.fun1=function () {
console.log(`我的名字是${this.name},我的年龄是${this.age}`) // /系统偷偷替我们做了
// return this }
}
obj = new show('ldq',18)
obj.fun1()
</script>
</html>
最新文章
- jQuery基础_2
- DataTable 中varchar 转换为 Double 后重新 排序。
- Install and configure Intel NIC teaming on R420
- MFC应用程序创建窗口的过程 good
- 建造者模式->;代码示例
- HDU Good Numbers (热身赛2)
- cocos2dx之lua项目开发中MVC框架的简单应用
- Portlet开发入门实例
- iOS开发之虾米音乐频道选择切换效果分析与实现
- 分布式事物(同样适用于dubbo事务等分布式事务)
- win10更新后出现System.ComponentModel.Win32Exception
- Android--UI之ScrollView
- 关于alter database datafile offline和alter database datafile offline drop 的区别
- window 命令大全
- 【linux】——cscope
- 内核poll机制
- https://www.cnblogs.com/beileixinqing/p/7724779.html vue-cli生成的项目配置开发和生产环境不同的接口 vue-cli生成的项目,vue项目配置了不同开发环境的接口地址,axios.defaults.baseURL如何引用这个地址,这是在我发布项目的时候考虑的,于是想到了
- Ajax 知识
- java有关构造器的面试题详解
- Cracking The Coding Interview4.5
热门文章
- vs问题解决:an operation is not legal in the current state
- linux基础练习题(2)
- VUE失去焦点提交修改值
- Github版本管理以及git使用
- weixinShare.js / 极简微信分享插件
- (Access denied for user &#39;root&#39;@&#39;slaver1&#39; (using password: YES))
- sublime3 破解
- python全栈开发day61-django简单的出版社网站展示,添加,删除,编辑(单表的增删改查)
- ionic2集成sdk后,连接超时的问题
- flink的集群的HA高可用