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

官方网站建设网站营销型网站设计公司哪里有

官方网站建设网站,营销型网站设计公司哪里有,今天的国内新闻,手机网站管理第一次听说伪数组这个概念#xff0c;听到的时候还以为是说CSS的伪类呢#xff0c;网上一查#xff0c;这东西原来还是个很常见的家伙。 何为伪数组 伪数组有两个特点#xff1a; 具有length属性#xff0c;其他属性#xff08;索引#xff09;为非负整数但是却不具备…第一次听说伪数组这个概念听到的时候还以为是说CSS的伪类呢网上一查这东西原来还是个很常见的家伙。 何为伪数组 伪数组有两个特点 具有length属性其他属性索引为非负整数但是却不具备数组的方法 也就是看起来像是数组然而并不是… 举个例子看看 函数内部的arguments function testArguments(a, b, c) {console.log(arguments is array: ${Array.isArray(arguments)});console.log(arguments[0]);console.log(arguments[1]);console.log(arguments[2]); } testArguments(1,2,3);2. DOM列表 JQuery选择得出的列表: $(‘div’) 随意找一个使用jq的网站例如https://www.jq22.com/ 如何判断真伪数组 使用instanceof 方法使用Array.isArray()方法: 未必准确见下文 使用伪数组.__proto__ Array.prototype;转换后不可用。伪数组.constructor Array; 适用于带constructor的场景Object.prototype.toString.call(arr) ‘[object Array]’ 尝试一下 function testArguments(a, b, c) {console.log(arguments is array: ${Array.isArray(arguments)});console.log(arguments is array: ${arguments instanceof Array});console.log(arguments is object: ${arguments instanceof Object});const newArguments Array.prototype.slice.call(arguments);console.log(newArguments is array: ${Array.isArray(newArguments)});console.log(newArguments is array: ${newArguments instanceof Array});console.log(newArguments is object: ${newArguments instanceof Object}); }testArguments(1,2,3);如何把伪数组转换成数组 Array.prototype.slice.call(); / Array.prototype.slice.apply();原型继承 伪数组.__proto__ Array.prototype;arguments 无影响正常使用ES6中数组的新方法 from() 方法一 Array.prototype.slice.call(); / Array.prototype.slice.apply(); function testArguments(a, b, c) {console.log(arguments is array: ${Array.isArray(arguments)});console.log(arguments[0]);console.log(arguments[1]);console.log(arguments[2]);const newArguments Array.prototype.slice.call(arguments);console.log(newArguments is array: ${Array.isArray(newArguments)});console.log(newArguments[0]);console.log(newArguments[1]);console.log(newArguments[2]); } testArguments(1,2,3);方法二 原型继承 伪数组.__proto__ Array.prototype;arguments 无影响正常使用 使用该方法进行转换时Array.isArray()方法不可用来进行判断。 方法三 ES6中数组的新方法 from() 尝试一下 function testArguments(a, b, c) {console.log(arguments is array: ${Array.isArray(arguments)});console.log(arguments is array: ${arguments instanceof Array});const newArguments Array.from(arguments);console.log(newArguments is array: ${Array.isArray(newArguments)});console.log(newArguments is array: ${newArguments instanceof Array}); } testArguments(1,2,3);总结 在使用判断是否为数组时如果无法知道数组是否可能是使用“原型继承”的方法转换得到的就不要使用Array.isArray()方法判断对象是否为数组的方法。在写转换方法时由于原型继承 伪数组.__proto__ Array.prototype;可能存在判断失误尽量使用Array.prototype.slice.call(); / Array.prototype.slice.apply();如果可以使用ES6使用Array.from()方法较为简单明了。
http://www.pierceye.com/news/276292/

相关文章:

  • 商丘给企业做网站的公司已备案域名租用
  • .net商城网站模板下载网站开发怎么对接客户
  • php程序员网站开发域名企业备案对网站的好处
  • 沈阳市城乡建设网站wordpress全文
  • 冉冉科技网站建设网络教学平台网址
  • 深圳网站设计建设公司宁波易通建设网站
  • 许昌网站建设公司网站的空间和域名
  • 公司查询网站查询系统wordpress简书主题
  • 公司网站 钓鱼网站ui设计交付物都包含哪些
  • seo网站导航建设技巧精东影视传媒文化管理公司
  • 做白酒的网站怎么查网站建设是哪家公司
  • 网站域名密码免费网站推广产品
  • 网站建设一般要多少费用申请网站官网
  • 金融网站织梦模板二手车网站建设
  • 怎么自己写代码做网站做网站必须用域名吗
  • 重庆营销网站建设平台怎么添加wordpress模板
  • 网站赚取广告费深圳个人外贸网站建
  • 在线销售型的网站巢湖城市建设投资有限公司网站
  • 苏州高端网站建设设计程序源代码网站
  • 基本原理网站建设文档怎么做网站链接
  • 网站建设出售门户网站有哪些推广分类
  • 企业网站制作一般多少钱做ppt的兼职网站有哪些
  • 分公司可以建设网站淘宝联盟怎么推广
  • 苏州网站设计哪家公司好童程童美编程地址在哪里
  • 软文营销的成功案例百度优化怎么做
  • 公司网站开发怎么收费优化方案英语必修三
  • 网站改版阿里云怎么做网站301定向温州网站运营
  • 免费做简历网站有哪些网站建设与网页制作招聘
  • 怎么到国外网站去接模具订单做潍坊微信网站开发
  • 做船公司网站青海公司网站建设哪家好