Javascript 基本二

来源:互联网 发布:淘宝企业店铺能撤销吗 编辑:程序博客网 时间:2024/05/21 19:25

1.  json string -> json object

var obj = JSON.parse(json-string);

2. 访问属性

objectName[expression]        

x = "age"; person[x]=18

遍历属性:

for (property-key in object) {
}

2.url字符串替换

'^\/organizations\/\w*\/user$':'./response/accounts.json'

->

'^\/organizations\/\w*\/user$':'./response/accounts.json'

var newKey = key.replaceAll('\\/','\\\/');
newKey = newKey.replaceAll('\\*','\\w*');
newKey = '^'+newKey+'$';


path.search(re) !== -1 匹配

0 0