📜  对象表示法字符串 javascript\ - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:18.296000             🧑  作者: Mango

代码示例1
function getValueFromNotation(obj: Object,is: string|any[], value: any = undefined) {
    
    if (typeof is == 'string')
      return getValueFromNotation(obj,is.split('.'), value);
    else if (is.length==1 && value!==undefined)
      return obj[is[0]] = value;
    else if (is.length==0)
      return obj;
    else
      return getValueFromNotation(obj[is[0]],is.slice(1), value);
  
}