Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@wingmeng

Description

@wingmeng
Issue body actions

类型:常用技巧
难度:★

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.