Clearing the console history is easy, right click on the Console window and select the "Clear console history" option from the context menu.
Golden rule: You cannot delete anything declared with var
If you want to hack your way through cleaning up the global scope you could identify what you've added by exploring the keys of the window object.
Object.keys(window)
Make a note of the keys you want to remove and then try to delete them:
['a', 'x'].map(prop => delete window[prop]);
Delete will try to remove the property from the window object and returns a boolean result, so you might end up with a response like
[true, false]
This indicates the first item was deleted but unfortunately the second was not.
In your case you could assign the x variable to null so it is marked for garbage collection but when will the window object go out of scope?