📜  如何在 js 中添加变量 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:29.988000             🧑  作者: Mango

代码示例4
// data from json: resp = {"home": 1, "landmark": 2}
// Method 1: 
// use ` for add variable
url = `workspace/detail/${resp.home}`;
console.log(url) -> // workspace/detail/1
  
// Method 2: 
// use ' and + for concentrace variable
url = 'workspace/detail/' + resp.home;
console.log(url) -> // workspace/detail/1