首页 > 解决方案 > Internet Explorer 8 - 新 Map() 替换

问题描述

是否有“var exampleMap = new Map();”的简单实现替代?Internet Explorer 8 支持的那个?在我编写应用程序并在 Chrome 中进行测试后,我意识到它不受支持。

我能想出的最佳解决方案是使用 [key, [values]],但它似乎效率极低。


function processData(allText) {
  var numOfColumns = 5;
  var allTextLines = allText.split(/\r\n|\n/);

  return allTextLines;
}

function parseArray(data) {

  var allText = processData(data);

  var systemApplication = new Map();

  for (var i = 1; i < allText.length; i++) {

    currentApplicationParameters = allText[i].split(",");
    currentApplicationName = currentApplicationParameters[0];

    var rsamApplicationProperties = function (entitlementName, environmentName, resourceSequence) {
      this.entitlementName = entitlementName;
      this.environmentName = environmentName;
      this.resourceSequence = resourceSequence;
    };

    if (systemApplication.has(currentApplicationName)) {
      var arrayOfAppParams = [];
      arrayOfAppParams = [systemApplication.get(currentApplicationName)];
      arrayOfAppParams[0].push(new rsamApplicationProperties(
        currentApplicationParameters[1], currentApplicationParameters[3], currentApplicationParameters[2]));
        var myNewArray = [].concat.apply([], arrayOfAppParams);
        systemApplication.set(currentApplicationName, myNewArray);

    } else {

      arrayOfAppParams = [new rsamApplicationProperties(currentApplicationParameters[1], currentApplicationParameters[3], currentApplicationParameters[2])];
      systemApplication.set(currentApplicationName, arrayOfAppParams);
    }
  }

标签: javascriptjqueryinternet-explorer-8

解决方案


推荐阅读