js map
// js通用方法 // map对象定义
function Map() {
var struct = function(key, value) {
this.key = key;
this.value = value;
}; var put = function(key, value) {
for (var i = 0; i < this.arr.length; i++) {
if (this.arr[i].key === key) {
this.arr[i].value = value;
return;
}
}
this.arr[this.arr.length] = new struct(key, value);
}; var get = function(key) {
for (var i = 0; i < this.arr.length; i++) {
if (this.arr[i].key === key) {
return this.arr[i].value;
}
}
return null;
}; var remove = function(key) {
var v;
for (var i = 0; i < this.arr.length; i++) {
v = this.arr.pop();
if (v.key === key) {
continue;
}
this.arr.unshift(v);
}
}; var size = function() {
return this.arr.length;
}; var isEmpty = function() {
return this.arr.length <= 0;
};
this.arr = new Array();
this.get = get;
this.put = put;
this.remove = remove;
this.size = size;
this.isEmpty = isEmpty;
}
js map的更多相关文章
- angularjs中 *.min.js.map 404的问题
初次使用AngularJS,在chrom调试的时候,出现如下问题: GET http://localhost:63342/luosuo/visitor/js/lib/angular-animate.m ...
- [Javascript] Creating an Immutable Object Graph with Immutable.js Map()
Learn how to create an Immutable.Map() through plain Javascript object construction and also via arr ...
- [Immutable.js] Working with Subsets of an Immutable.js Map()
Immutable.js offers methods to break immutable structures into subsets much like Array--for instance ...
- [Immutable.js] Differences between the Immutable.js Map() and List()
The Immutable.js Map() is analogous to a Javascript Object or Hash since it is comprised of key-valu ...
- js.map error
1. 问题: 1.1 通过bower install 的components 许多在运行的时候报404无法找到js.map文件, 如图: 2. 分析: 2.1 查看 ...
- 自定义JS Map 函数
// 自定义JS Map 函数 function Map() { var map = function (key, value) {//键值对 this.key = key; this.value = ...
- js map(Number) All In One
js map(Number) All In One map() 方法创建一个新数组,其结果是该数组中的每个元素是调用一次提供的函数后的返回值. let newArray = arr.map(callb ...
- js map & Number
js map & Number const regionIds = `1,2,3`; // "1,2,3" regionIds.split(',').map(Number) ...
- JS Map 和 List 的简单实现代码
javascript中是没有map和list 结构的. 本篇文章是对在JS中Map和List的简单实现代码进行了详细的分析介绍,需要的朋友参考下 代码如下: /* * MAP对象,实现MAP功能 * ...
随机推荐
- ueditor编辑器和at.js集成
源码: <%@ page language="java" import="java.util.*" pageEncoding="UTF-8&qu ...
- HTML5 ——本地存储
目录 一.HTML4客户端存储 1.1.提交表单发送到服务器的信息 1.2.客户端本地存储概要 二.localStorage 2.1.添加 2.2.取值 2.3.修改 2.4.删除 2.5.跨页面与跨 ...
- 自己动手写js分享插件(QQ空间,微信,新浪微博。。。)
参考博客:http://blog.csdn.net/libin_1/article/details/52424340 下载链接:http://download.csdn.net/detail/come ...
- asp.net webAPI 自动生成帮助文档并测试
之前在项目中有用到webapi对外提供接口,发现在项目中有根据webapi的方法和注释自动生成帮助文档,还可以测试webapi方法,功能很是强大,现拿出来与大家分享一下. 先看一下生成的webapi文 ...
- 运用JMX监控Tomcat/Java jvisualvm简要说明
公司线上项目出现了java heap space 然后经过查询知晓了下面工具于是开始了尝试. visualvm能干什么:监控内存泄露,跟踪垃圾回收,执行时内存.cpu分析,线程分析... jvisua ...
- LoadRunner在移动端性能测试的应用
摘选自 <精通移动app测试实战:技术.工具和案例>新书上市 如果大家之前做过性能测试,我相信一定会应用过大名鼎鼎的性能测试工具-LoadRunner.目前LoadRunner的最新版本为 ...
- Redis监控技巧(转)
来自:http://blog.nosqlfan.com/html/4166.html Redis 监控最直接的方法当然就是使用系统提供的 info 命令来做了,你只需要执行下面一条命令,就能获得 Re ...
- XML 和 List 互转类
XML 和 List 互转类 using System; using System.Collections.Generic; using System.Linq; using System.Text; ...
- https SSL主流数字证书都有哪些格式?
主流数字证书都有哪些格式? 一般来说,主流的Web服务软件,通常都基于两种基础密码库:OpenSSL和Java. Tomcat.Weblogic.JBoss等,使用Java提供的密码库.通过Java的 ...
- 使用Gradle自动发布Java Web到SAE
博客已迁移,请访问:http://www.huangyunkun.com/ 现在像SAE这类的应用引擎已经比较多了,百度和腾讯都出了这样的东西. 我很早的时候就开始用SAE,当时还为了迁就SAE学习了 ...