BecauseIE8 Not supported for versions up toMap object, This paper provides an effective solution for program apes.

This article rewritesMap object, Commonset, get, put, clear, remove, delete, forEach, has, containsKey, isEmpty, size  Other methods, Trial and normal statement of use and declarationMap Same object:

var map = new Map();

Just copy the following code into<script type="text/javascript"></script> Then you can.

function Map() {
        this.elements = new Array();
        //  ObtainMap Element number
        this.size = function() {
            return this.elements.length;
        },
        //  judgeMap Is it empty?
        this.isEmpty = function() {
            return (this.elements.length < 1);
        },
        //  deleteMap All elements
        this.clear = function() {
            this.elements = new Array();
        },
        //  towardsMap Add elements to(key, value)
        this.put = function(_key, _value) {
            if (this.containsKey(_key) == true) {
                if (this.containsValue(_value)) {
                    if (this.remove(_key) == true) {
                        this.elements.push({
                            key : _key,
                            value : _value
                        });
                    }
                } else {
                    this.elements.push({
                        key : _key,
                        value : _value
                    });
                }
            } else {
                this.elements.push({
                    key : _key,
                    value : _value
                });
            }
        },
        //  towardsMap Add elements to(key, value)
        this.set = function(_key, _value) {
            if (this.containsKey(_key) == true) {
                if (this.containsValue(_value)) {
                    if (this.remove(_key) == true) {
                        this.elements.push({
                            key : _key,
                            value : _value
                        });
                    }
                } else {
                    this.elements.push({
                        key : _key,
                        value : _value
                    });
                }
            } else {
                this.elements.push({
                    key : _key,
                    value : _value
                });
            }
        },
        //  Delete specifiedkey Elements, Successful returntrue, Failure to returnfalse
        this.remove = function(_key) {
            var bln = false;
            try {
                for (i = 0; i < this.elements.length; i++) {
                    if (this.elements[i].key == _key) {
                        this.elements.splice(i, 1);
                        return true;
                    }
                }
            } catch (e) {
                bln = false;
            }
            return bln;
        },

        //  Delete specifiedkey Elements, Successful returntrue, Failure to returnfalse
        this.delete = function(_key) {
            var bln = false;
            try {
                for (i = 0; i < this.elements.length; i++) {
                    if (this.elements[i].key == _key) {
                        this.elements.splice(i, 1);
                        return true;
                    }
                }
            } catch (e) {
                bln = false;
            }
            return bln;
        },
        
        //  Get assignedkey Element valuevalue, Failure to returnnull
        this.get = function(_key) {
            try {
                for (i = 0; i < this.elements.length; i++) {
                    if (this.elements[i].key == _key) {
                        return this.elements[i].value;
                    }
                }
            } catch (e) {
                return null;
            }
        },

        // set Appointkey Element valuevalue
        this.setValue = function(_key, _value) {
            var bln = false;
            try {
                for (i = 0; i < this.elements.length; i++) {
                    if (this.elements[i].key == _key) {
                        this.elements[i].value = _value;
                        return true;
                    }
                }
            } catch (e) {
                bln = false;
            }
            return bln;
        },

        //  Gets the element of the specified index( Useelement.key,element.value Obtainkey andvalue), Failure to returnnull
        this.element = function(_index) {
            if (_index < 0 || _index >= this.elements.length) {
                return null;
            }
            return this.elements[_index];
        },

        //  judgeMap Does it contain the specifiedkey Elements
        this.containsKey = function(_key) {
            var bln = false;
            try {
                for (i = 0; i < this.elements.length; i++) {
                    if (this.elements[i].key == _key) {
                        bln = true;
                    }
                }
            } catch (e) {
                bln = false;
            }
            return bln;
        },

        //  judgeMap Does it contain the specifiedkey Elements
        this.has = function(_key) {
            var bln = false;
            try {
                for (i = 0; i < this.elements.length; i++) {
                    if (this.elements[i].key == _key) {
                        bln = true;
                    }
                }
            } catch (e) {
                bln = false;
            }
            return bln;
        },
        
        //  judgeMap Does it contain the specifiedvalue Elements
        this.containsValue = function(_value) {
            var bln = false;
            try {
                for (i = 0; i < this.elements.length; i++) {
                    if (this.elements[i].value == _value) {
                        bln = true;
                    }
                }
            } catch (e) {
                bln = false;
            }
            return bln;
        },

        //  ObtainMap All inkey Array(array)
        this.keys = function() {
            var arr = new Array();
            for (i = 0; i < this.elements.length; i++) {
                arr.push(this.elements[i].key);
            }
            return arr;
        },

        //  ObtainMap All invalue Array(array)
        this.values = function() {
            var arr = new Array();
            for (i = 0; i < this.elements.length; i++) {
                arr.push(this.elements[i].value);
            }
            return arr;
        };
        
        /**
        * map Traversing array
        * @param callback [function]  Callback function;
        * @param context [object]  context;
        */
        this.forEach = function forEach(callback,context){
            context = context || window;
            
            //IE6-8 Write the logic of callback function execution
            var newAry = new Array();
            for(var i = 0; i < this.elements.length;i++) {
                if(typeof  callback === 'function') {
                    var val = callback.call(context,this.elements[i].value,this.elements[i].key,this.elements);
                    newAry.push(this.elements[i].value);
                }
            }
            return newAry;
        }

    }