源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

javascript 有趣而诡异的数组

  • 时间:2020-08-28 04:47 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:javascript 有趣而诡异的数组
年前在重写淘宝旺铺里的会员卡脚本的时候,无意中发现了一个有趣的事情。代码类似:
[url=http://andrewdupont.net/2006/05/18/javascript-associative-arrays-considered-harmful/]《JavaScript “Associative Arrays” Considered Harmful》[/url]): [quote] JavaScript arrays (which are meant to be numeric) are often used to hold key/value pairs. This is bad practice. Object should be used instead. //大意:[b]数组只支持数字的,键值对应使用于对象上。[/b] [/quote]There is no way to specify string keys in an array constructor. //在数组构造函数中无法定义字符串键值 There is no way to specify string keys in an array literal. //在数组字面量中无法定义字符串键值 Array.length does not count them as items. // Array.length 不会计算字符串键值 进一步窥探数组: 1、数组可以根据所赋的值自动调整大小
[url=http://west-wind.com/Weblog/posts/608772.aspx]《Javascript Array Fun》[/url] [/list] 2、可使用[b]“The Miller Device”[/b] 方法来判断是否是数组
[url=http://blog.360.yahoo.com/blog-TBPekxc1dLNy5DOloPfzVvFIVOWMB0li?p=916]《The Miller Device》[/url] [*][url=http://ajaxian.com/archives/isarray-why-is-it-so-bloody-hard-to-get-right]《isArray: Why is it so bloody hard to get right?》[/url] [/*][/list]
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部