javascript-序列化,时间,eval,转义

一:序列化

  JSON.stringify(li) 将对象转字符串

  JSON.parse(str1) 将字符串转对象

    li=[11,22,33]
    [11, 22, 33]
    li
    [11, 22, 33]
    JSON.stringify(li)
    "[11,22,33]"
    JSON.parse()
    Uncaught SyntaxError: Unexpected token u VM174:2
    str1=JSON.stringify(li)
    "[11,22,33]"
    JSON.parse(str1)
    [11, 22, 33]

二:转义

  encodeURI URI中未转义的字符

  decodeURI URI中转义字符

  encodeURIComponent URI组件中未转义的字符

  decodeURIComponent

  escape 对字符转义

  unescape 给转义字符解码

  URIError 由URI编码和解码抛出的异常

  客户端(cookie) =>服务器端

  将数据经过转义后,保存在cookie中

    url="http://sogou.com/web?query=理解"
    "http://sogou.com/web?query=理解"
    new_url=encodeURI(url)
    "http://sogou.com/web?query=%E7%90%86%E8%A7%A3"
    decodeURI(new_url)
    "http://sogou.com/web?query=理解"
    new_url2=encodeURIComponent(url)
    "http%3A%2F%2Fsogou.com%2Fweb%3Fquery%3D%E7%90%86%E8%A7%A3"
    decodeURIComponent(new_url2)
    "http://sogou.com/web?query=理解"

三:eval

  

  python 是这样eval("表达式")

      exec(执行代码),只是执行,没有返回值

  JS

  eval 是python里这两个功能的合集

四:时间

Date对象 类

var d=new Date()

d.getXX 表示获取

d.setXX 表示设置