Simplify simple object clear function with Javascript
The clear function relies on the global data variable. This could be more portable by passing the object in as the first argument, and then the fields as the second argument

clear(data); // clear all
clear(data, "one"); // clears the "one" field
clear(data, ["one", "two"]); // clears multiple fields

Checking if (fields !== undefined) will accept null values as a field name. A "truthy" check is probably what you need:

if (fields) {
  // ...
} else {
  // ...
}

What does "clear" mean? Your code assumes that all fields in an object should be cleared out to an empty string. What if the original value was a boolean, or number? Maybe you want to set that field to null instead. Better yet, maybe set it to null then delete the field:

data[field] = null;
delete data[field];



Other than that, it looks pretty good.