How to append a string value during assignment in Javascript?

前端 未结 7 1071
故里飘歌
故里飘歌 2020-12-10 08:04

Hey i dont know if that is possible but i want to set a given variable in js by reference.

What i want to do is, that each time i pass a string to t

7条回答
  •  春和景丽
    2020-12-10 08:53

    You can clone the object by first converting it to JSON (watch out for circular references) and then parse it back again. Like so:

    function clone(obj) {
      return JSON.parse(JSON.stringify(obj));
    }
    

    This uses the internal browser's JSON routines (safer & faster than using an external resource). If you simply must have backwards compatibility you can download the core JSON routines from JSON.org.

提交回复
热议问题