A few points it took me a long time to learn:
1. It is always a good idea to network about potential jobs, so do it all every time you can. Networking is by far the most used method to find a job beyond entry level. Companies are in business to make a profit and any idea of long term commitment today is mostly a figment of one's imagination, except for a few, mostly small, companies.
2. If you are in a small company, expect nepotism. Recognize that if you are not related to the owner, your ability to get promoted is limited.
3. No company will ever pay you what your job is worth, except if you own the company.
4. Never threaten to leave explicitly. Express your goals and desires and contribute to the company's success. If they have any sense, then will recognize your contributions and aid you reaching your goals.
5. Once you decide to leave, the normal expectation is 2 weeks notice, you do not need to tell them before that. A lot of companies have a policy of escorting your off the premises immediately, so do not be shocked if this happens. You will want to have already discreetly taken your own valuables off site.
6. If your leaving leaves a big hole in their operations, it is possible they will make a counter-offer of a bonus, a raise or even a promotion. You almost never want to accept it as the company will be making other plans to cover up that hole as fast as possible and then you are redundant.
7. If you do decide to leave (and are not being fired), you will often have an exit interview. The main goal by far from your perspective is to get the check mark that says you can be rehired. It might feel good to tell someone how badly your boss treated you, but mostly that will make you look like someone they do not want to ever rehire. Keep your options open.