The 2 are different.
The password manager included in your browser usually store your password on your file system and protect them using your operating system account. For example, on windows, if you want to view your saved passwords you need to enter your windows credentials.
Lastpass on the other hand store your passwords on their server and encrypt them using the master password associated with your lastpass account.
Let's look at the problems of each
Browser password manager : It assumes that your operating system account is secure. If someone else know your operating system account password they can steal all the password in your manager. In chrome, for example, it seems that your password are simply in plain text on your file system. So, if you let your session open and left your computer, anyone can steal you password. An administrator of the operating system can probably do it aslo...
But with Firefox, you have the option to select a master password to encrypt/decrypt your password. If you select this option, your passwords should be safe even if someone else access your computer.
Lastpass : It assumes that you are the only one to know your master password, which is probably true. On the other hand, if someone is able to find your master password (maybe by hacking into lastpass) then they will have access to all your passwords.
I would say that both options are good enough : firefox with master password and lastpass.
About the use of javascript to encode your password.
I would say it's mostly a gimmick from LastPass to make you feel more secure but it's not a problem really. A quote from them :
All sensitive data is encrypted and decrypted locally before syncing
with LastPass. Your key never leaves your device, and is never shared
with LastPass. Your data stays accessible only to you.
They claim that it's more secure because lastpass itself can't even know your master password since it will never receive it. But in reality, since they control the javascript, does it makes a big difference if they encrypt/decrypt locally or on their server? In general no. They could remove the javascript whenever they want to receive your master password directly if they want.
But back to the javascript... When their page is secure, an attacker cannot modify the javascript.If their page was insecure, an attacker could simply log everything that you type and steal your master password anyway. The use of javascript to encrypt/decrypt is irrelevant here, you just need to ask yourself if their page is secure or not and it probably is.
But, they do claim that is saved them from the heartbleed attack.
However, LastPass is unique in that your data is also encrypted with a
key that LastPass servers don’t have access to. Your sensitive data is
never transmitted over SSL unencrypted - it’s already encrypted when
it is transmitted, with a key LastPass never receives. While this bug
is still very serious, it could not expose LastPass customers’
encrypted data due to our extra layers of protection. On the majority
of the web, user data is not encrypted before being transmitted over
SSL, hence the widespread concern.
Source