https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call
function Product(name, price) {
this.name = name;
this.price = price;
} function Food(name, price) {
Product.call(this, name, price);
this.category = 'food';
} function Toy(name, price) {
Product.call(this, name, price);
this.category = 'toy';
} var cheese = new Food('feta', 5);
var fun = new Toy('robot', 40);
var animals = [
{ species: 'Lion', name: 'King' },
{ species: 'Whale', name: 'Fail' }
]; for (var i = 0; i < animals.length; i++) {
(function(i) {
this.print = function() {
console.log('#' + i + ' ' + this.species
+ ': ' + this.name);
}
this.print();
}).call(animals[i], i);
}
function greet() {
var reply = [this.person, 'Is An Awesome', this.role].join(' ');
console.log(reply);
} var i = {
person: 'Douglas Crockford', role: 'Javascript Developer'
}; greet.call(i); // Douglas Crockford Is An Awesome Javascript Developer
 

最新文章

  1. 重量级Orchard模块发布 - 模块生成工具RaisingStudio.ModuleGenerator
  2. Error:&ldquo;应用程序无法正常启动(0xc000007b)。请单击&ldquo;确定&rdquo;关闭应用程序。&rdquo;
  3. iOS开发编译报错、常见问题(实时更新)
  4. java学习第9天
  5. dd 生成指定大小文件
  6. Oboe 提升web 用户体验以及性能
  7. java开发常用命令
  8. Docker系列之(一):10分钟玩转Docker(转)
  9. SQLServer修改数据列
  10. imx6 工具链下载地址
  11. [leetcode]7. Reverse Integer反转整数
  12. centos7使用kubeadm配置高可用k8s集群
  13. linux 如何快速的查找日志中你所要查找的信息
  14. widget jquery 理解
  15. linux下的usb转串口的使用(修改)【转】
  16. javascript 完美解决对联广告
  17. BZOJ 2745: [HEOI2012]Bridge
  18. SQL: 查找空值
  19. 转:如何转换Android打包用jks格式keystore证书为Air用pkcs12格式p12证书
  20. JXM 监控tomcat 7(含代码

热门文章

  1. 62. Unique Paths不同路径
  2. 2017-3-31/socket
  3. 牛客网 PAT 算法历年真题 1001 : A+B和C (15)
  4. 微信小程序自动定位,通过百度地图根据经纬度获取该地点所在城市信息
  5. 把旧系统迁移到.Net Core 2.0 日记(11) -- Authentication 认证 claimsIdentity 对比 之前的FormAuthentication
  6. python(6)之文件
  7. Node.js是用来干嘛的
  8. 基本git指令
  9. laravel基于Bootstrap的成功和失败的提示信息和验证提示信息
  10. shell 流程控制语句