Eval() = Unexpected token : error

前端 未结 8 1797
囚心锁ツ
囚心锁ツ 2020-12-09 04:28

I tried this simple JavaScript code:

eval(\'{\"Topics\":[\"toto\",\"tata\",\"titi\"]}\')

In the Chrome console, for example, this returns

8条回答
  •  温柔的废话
    2020-12-09 04:41

    Number one: Do not use eval.

    Number two. Only use eval to make something, well be evaluated. Like for example:

    eval('var topics = {"Topics":["toto","tata","titi"]}');
    

提交回复
热议问题