javascript - Typescript hasOwnProperty equivalent -


in javascript if want loop through dictionary , set properties of dictionary, i'd use this:

for (let key in dict) {   if (obj.hasownproperty(key)) {     obj[key] = dict[key];   } } 

if obj typescript object (instance of class), there way perform same operation?

if obj typescript object (instance of class), there way perform same operation?

your javascript valid typescript (more). can use same code is.

here example:

class foo{     foo = 123 }  const dict = new foo(); const obj = {} foo;  (let key in dict) {   if (obj.hasownproperty(key)) {     obj[key] = dict[key];   } } 

note: recommend object.keys(obj).foreach(k=> javascript not question asking here.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -