当前位置: 首页 > news >正文

爱网站关键词查询广州企业一网通办

爱网站关键词查询,广州企业一网通办,做食品网站有哪些,公司名称被大量网站收录object.prototype.call /* * object.prototype.call * 当一个object没有某个方法#xff0c;但是其他的有#xff0c;我们可以借助call或apply用其它对象的方法来操作。 * 语法: fun.call(thisArg[, arg1[, arg2[, ...]]]) * param: thisArg {object} //当前引用对象 … object.prototype.call /* * object.prototype.call * 当一个object没有某个方法但是其他的有我们可以借助call或apply用其它对象的方法来操作。 * 语法: fun.call(thisArg[, arg1[, arg2[, ...]]]) * param: thisArg {object} //当前引用对象 * 不传参数,传null,undefined, this指向window对象 * 传递另一个函数的函数名fun2, this指向函数fun2的引用 * 传递一个对象,函数中的this指向这个对象 * 值为原始值(数字,字符串,布尔值), this会指向该原始值的自动包装对象,如String,Number,Boolean * param: arg1, arg2, ... {object} // arguments参数 */   call函数中的this指向 function a(){console.log(this); } function b(){}var objthis {name: Alan}; //定义对象 a.call(); // window a.call(null); // window a.call(undefined); // window a.call(1); // Number {[[PrimitiveValue]]: 1} a.call(); // String {length: 0, [[PrimitiveValue]]: } a.call(true); // Boolean {[[PrimitiveValue]]: true} a.call(b); // function b(){} a.call(objthis); // Object {name: Alan}   使用call对象的构造函数链 function Product(name, price){this.name name;this.price price;if(price 0){throw RangeError(Cannot create product this.name with a negative price);} }// call方法 function Food(name,price){Product.call(this,name,price);this.category food; }// 等同于 function Food(name,price){this.name name;this.price price;if(price 0){throw RangeError(Cannot create product this.name with a negative price);}this.category food; }   使用call调用匿名函数 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(){this.print function(){console.log(# i animals[i].species : animals[i].name);}this.print();})();*/ }   使用call调用函数的上下文this function greet(){var reply [this.person, Is An Awesome, this.role].join( );console.log(reply); }var obj {person: Douglas Crockford, role: Javascript Developer };greet.call(obj);   以DOM为例子 function changeStyle(attr, value){this.style[attr] value; } var box document.getElementById(box); window.changeStyle.call(box, height, 200px); window.changeStyle.apply(box, [height, 200px]);   // 不用call  function say(name){console.log(this , name);}say.call2 function( thisObj, arg1 ) {thisObj new Object( thisObj );thisObj.say this;return thisObj.say(arg1);};say.call2(hola,Mike);   转载于:https://www.cnblogs.com/alantao/p/5882411.html
http://www.yutouwan.com/news/35344/

相关文章:

  • 俄语网站制作国产wordpress模板
  • 学校网站建设规划网页制作与网站建设英文翻译
  • 医院网站加快建设方案广州网络平台
  • 购物网站 开店重庆梁平网站建设公司
  • 网站建设 9awordpress 免备案cdn
  • 聊城网站建设设计简易手机网站开发
  • 找做cad彩拼的网站网站建设管理考核办法
  • 网站做加QQ群链接易记域名网站大全
  • 秦皇岛网站建设找汉狮网站建设的点子
  • 网站开发 相册wordpress优惠券发放插件
  • 织梦协会网站模板外贸网站建设 杭州
  • wap网站源码下载广州市招投标网站
  • 商洛网站建设公司电话wordpress直接购买
  • 中邦建设工程有限公司官方网站上海莱布拉网站建设
  • php学多久可以做网站网站推广做百度还是360
  • 山东农业大学学风建设专题网站中英版网站怎么做
  • wordpress建企业网站设置简述企业建设网站的必要性
  • 网站小程序开发公司家装公司加盟哪个公司好
  • 安徽 建设 招聘信息网站西安计算机培训机构
  • 佛山外贸网站建设资讯wordpress留言板自定义
  • 网站申请注册 免备案深圳网站建设公司哪家
  • 网络设计涉及到的核心标准是正规网站优化推广
  • 邹城市网站建设自己架设网站备案
  • 国外 上海网站建设甘肃建设厅网站
  • 网站标题格式做类似58同城大型网站
  • 公司网站备案流程二维码生成器app下载安卓版
  • 哪家网站建设公司比较好恶意镜像网站程序
  • 比价网站源码整站程序wordpress去掉工具栏
  • wordpress直播网站主题购买空间网站哪个好
  • 国外搜索引擎网站用美图秀秀做网站图片