Q:

How to erase only the values of an object?

I have the following object:
obj = {"foo":"bar", "foo2":"bar2", "foo3":"bar3"};

I've been trying with a few iterations but haven't been able to catch the values (bar, bar2, bar3), only the keys. 
What I need to do is to clear those values, so the keys happen to be all empty. 
I've tried the following:
$.each( obj, function( key, value ) {
  delete value;
// or also: value = '';
});

And also stuff like:
$(obj).each(function (key,value) -- //same content as last one.

Object.values(obj).forEach(function (key) {
  var value = obj[key];
});

A:

Iterate through that object and set the value to null/undefined or whatever you want as empty value.

var obj = {"foo":"bar", "foo2":"bar2", "foo3":"bar3"};
Object.keys(obj).forEach(k => { obj[k] = null; })

console.log(obj);

Or if you want to remove the key, use delete:

var obj = {"foo":"bar", "foo2":"bar2", "foo3":"bar3"};
Object.keys(obj).forEach(k => { delete obj[k]; })

console.log(obj);

