title: how to nullify object values in javascript
body: <p>Lets assume I have object such as;</p>
  
  <pre><code>var obj = {
      name: "alex",
      surname: "black",
      age: 21,
      grade: 14
  }
  </code></pre>
  
  <p>I want to nullify all values as;</p>
  
  <pre><code>var obj = {
      name: "",
      surname: "",
      age: 0, 
      grade: 0
  }
  </code></pre>
  
  <p>How can I do this? I can look through keys by <code>Object.keys(obj)</code> and nullify each key according to their type.</p>
  
  <p>Like;</p>
  
  <pre><code>var str ="";
  for(var i =0; i &lt; obj.length; i++){
     if(type of obj[i] === "string")
        str += Object.keys(obj)[i] + ': "",\n';
     if(type of obj[i] === "integer")
        str += Object.keys(obj)[i] + ': 0,\n';
  
  }
  </code></pre>
  
  <p>Is it the proper way to do it?</p>
  
  <p>edit: Thank you for your all answers. But this object can also contain objects. So I should loop through all the keys and nullify them as your example shows. Am I right?</p>