The best way to learn a programming language is to do it, find some project that you want to work on and starts working on it. I have a bad habit of just watching hours long youtube tutorial on a language ? but then after that I barely remembers anything, but it gives you an idea of what u can do with it. Normally what i do is I watch the video first, then starts to work on the project at the same time searching more on how I do it. Slowly coding your project, I am sure you will be able to remember what u coded
Books are definitely one of the best resources to learn. Books are the most coherent source of learning, and each book is the result of a writer's many years of endeavor, so that the author selects and writes one part of his book obsessively. Books are also the most complete source of learning and include everything.
I believe learning programming from the book for beginners is very informative and useful because it involves all the concepts, and I suggest this at least to begin with. Also, programming books as a good reference can always help you whenever necessary.
I find that having a solid IDE which has a debugger embedded helps significantly.
I hate having to remember all the classes and methods in Java/JS, however the "best" IDEs (for me) will give you code completion/hints.
Programming PHP, for instance, is tough if you rely only echo/print_r/var_dump for debugging. However, a decent step by step debugger with watches (hopefully in the tooltip of the mouse) makes the job of finding bugs/mistakes ever so easier.
Thus, having a local development/sandbox environment (for speed of updating/debugging), a good IDE and debugger will add learning from your own mistakes to the mix. And that way is the best one I have found to learn programming.