Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Declared javascript object set to null values

It's a simple question i have, I have a javascript object which is declared like this -

   adminID = {"Name": "","AdminId": ""}

At a later point in the code i assign it some values -

  adminID = {"Name": "xyzabc","AdminId": "123123"}

Now, how can i assign the values back to null so my object looks like

  adminID = {"Name": "","AdminId": ""}

Is there a smarter way to do it or should i specify all the keys to null individually.

Cheers!

like image 823
verdure Avatar asked Mar 20 '26 14:03

verdure


1 Answers

You'd do it like this in JavaScript:

for(var p in adminID)
    if(adminID.hasOwnProperty(p))
        adminID[p] = '';
like image 152
mu is too short Avatar answered Mar 23 '26 04:03

mu is too short



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!