If you want to edit some complex javascript I suggest you use JsFiddle.
Alternatively, for smaller pieces of javascript you can just run it through your browser URL bar, here's an example:
javascript:alert("hello world");
And, as it was already suggested both Firebug and Chrome developer tools have Javascript console, in which you can type in your javascript to execute. So do Internet Explorer 8+, Opera, Safari and potentially other modern browsers.