js定义函数:

<script>
function A() {}
let a1 = new A();
let a2 = new A();
// 为A类添加原型 => 类似于类属性
A.prototype.num = 100;
console.log(a1.num);
console.log(a2.num);
</script>

ES6语法下类

class B {
constructor(name) {
this.name = name;
}
}
let b1 = new B('Tom');
let b2 = new B('Ben');
B.prototype.count = 666;
console.log(b1.count);
console.log(b2.count); console.log(b1.name);
console.log(b2.name);

最新文章

  1. JAVA中的Fork/Join框架
  2. resin 安装配置
  3. 【LeetCode OJ】Construct Binary Tree from Preorder and Inorder Traversal
  4. centos 7.0 菜鸟接触命令 记录
  5. C语言基础--for循环
  6. Rebar:Erlang构建工具
  7. IIS短文件名泄露漏洞危害及防范方法
  8. 自己用的一个ASP.Net MVC分页拿出来分享下(转)
  9. RequireJS示例
  10. flash 类和对象的关系
  11. IIS7.5 请求的内容似乎是脚本,因而将无法由静态文件处理程序来处理。=
  12. 解决cors跨域的filter
  13. window7环境下ZooKeeper的安装及运行
  14. WinForm界面设计-Button添加背景图去边框
  15. oracle经验记录
  16. lambda 表达式拼接
  17. 前端框架VUE----node.js的简单介绍
  18. oepnni安装
  19. swift学习之Label
  20. python 获取网页编码格式

热门文章

  1. 【AtCoder】ARC060
  2. gcc命令-更新中....
  3. Wannafly挑战赛22
  4. Eclipse中项目本身没有问题,可是工程名却有红色小叉叉解决办法
  5. javaIO——PipedReader 和 PipedWriter 实现模拟即时聊天
  6. ant-design的Table组件自定义空状态
  7. sql简易教程
  8. merge into 笔记
  9. C++ STL 之 set 和 pair
  10. ASE2019 model组 事后诸葛亮会议记录