You can embed javascript using a content  Editor web  part.

There are certain limitations like embedding a startup script or declaring
variables in some cases. There are workarounds as well like you have to push
your startup functions to a function stack and it gets executed.


It is not straight forward to get the source editor  popup.As you know content
editor webpart now allows inplace editing.Put your cursor in editor and wait for
couple of seconds so that Editing Ribbon appears.
Under Editing Tools -> Format Text you will find "HTML" button under "Markup"
group. Select the dropdown menu and select Edit HTML source.