PHP学习_PHP技术_PHP网站建设_PHP程序员专注于PHP技术研究及学习

Adophper » 前端设计 » js实现key,value

js实现key,value

此文被围观1980日期: 2013-12-21 分类 : 前端设计  标签:  ····
js实现key,value 方式一
var hashMap = {};

        hashMap['key1'] = 'value1';
        hashMap['key2'] = 'value2';
        hashMap['key3'] = 'value3';
        hashMap['key4'] = 'value4';
        hashMap['key5'] = 'value5';
        hashMap['key6'] = 'value6';

        if( 'key2' in hashMap)
        {
                alert('existance');
        }

        for(value in hashMap)
        {
                alert(value);
        }
方式2
var hashMap = {   
    Set : function(key,value){this[key] = value},   
    Get : function(key){return this[key]},   
    Contains : function(key){return this.Get(key) == null?false:true},   
    Remove : function(key){delete this[key]}   
}

本站使用ThinkPHP框架开发读图网主题,目前托管在阿里云,图片由读图网提供. 蜀ICP备12031064号

Copyright © 2011-2017adophper.com All Rights Reserved.