Skip to content

第 10 期(2019-05-17):JSON.parse方法polyfill #12

@wingmeng

Description

@wingmeng

类型:常用技巧
难度:★

JSON.parse() 方法写一个 polyfill,使其可以兼容低版本浏览器(IE8)

JSON.parse() 相关资料


参考答案:

!(window.JSON && window.JSON.parse) && !function(win) {
  win.JSON = {
    parse: function(str) {
      return new Function('return ' + str)()
    }
  }
}(window);

本期优秀回答者: @AMY-Y

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions