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功能 * ...
随机推荐
- duilib进阶教程 -- 扩展duilib的消息 (11)
duilib并没有提供双击和右键消息,所以需要我们自行扩展,这里以添加双击消息为例, 在UIDefine.h里,我们只看到了DUI_MSGTYPE_CLICK消息,却没有看到双击消息,因此需要在这里添 ...
- Windows 10 Java环境变量配置
Win10下 Java环境变量配置 首先,你应该已经安装了 Java 的 JDK 了(如果没有安装JDK,请跳转到此网址:http://www.oracle.com/technetwork/java/ ...
- Android Application 对象介绍
What is Application Application和Actovotu,Service一样是android框架的一个系统组件,当android程序启动时系统会创建一个 application ...
- FGPA 双向 IO 自动方向控制
Using a Virtex Device to Drive 5V CMOS-Level Signals Voltage Level-Shifter Output Waveform
- 取代奶瓶Minidwep-gtk破解WPA 全攻略
取代奶瓶Minidwep-gtk 破 WPA 全攻略 目录 1. CDlinux 下使用 minidwepgtk 获取握手包并使用自带的字典破解 2. 自带的字典破解不出密码时使用 U 盘外挂字典继 ...
- solr详解,开发必备
1.基础知识 创建索引的过程如下: (1).建立索引器IndexWriter,这相当于一本书的框架 (2).建立文档对象Document,这相当于一篇文章 (3).建立信息字段对象Field,这相当于 ...
- Java中long和Long有什么区别 (转载)
“Long is a class. long is a primitive. That means Long can be null, where long can't. Long can go an ...
- CMD command
过滤字符串查找:netstat -aon|findstr "80"
- old header
海纳百川 山不拒土 No Backspace in Real Life. Love Life![Cloud][LBS][GIS][GPS][MAPS][C++][Java]
- Android源码分析-全面理解Context
前言 Context在android中的作用不言而喻,当我们访问当前应用的资源,启动一个新的activity的时候都需要提供Context,而这个Context到底是什么呢,这个问题好像很好回答又好像 ...