Skip to content

Instantly share code, notes, and snippets.

@btshft
Created April 21, 2020 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save btshft/f15f590f9fc4518095eabc47c14c0405 to your computer and use it in GitHub Desktop.
Save btshft/f15f590f9fc4518095eabc47c14c0405 to your computer and use it in GitHub Desktop.
private initNullProperties(target : any, source: any){
let self = this;
Object.keys(target).forEach(targetKey =>{
if(target[targetKey] === null && source!== null && typeof source !== "undefined" && source[targetKey] !== null && typeof source[targetKey] === "object"){
target[targetKey] = source[targetKey];
}
else if(target[targetKey] !== null && typeof target[targetKey] === "object" && source!== null && typeof source !== "undefined"){
self.initNullProperties(target[targetKey], source[targetKey])
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment