Yes and no. People tend to be split regarding this question, either people absolutely trash the idea of learning japanese from anime or people are strong proponents of it. My opinion is that the truth is somewhere in the middle. It really depends on when and how you incorporate watching anime or reading manga into your japanese learning process. Right off the bat, I would say don’t use anime as a learning tool in the beginning. You really need a solid foundation before you start consuming media and learning by context. So at the very least, you should have studied both genki books or both minna no nihongo books and be at JLPT 4 level or higher.
If you start relying on anime from the get go you will start using lingo in the wrong context without knowing it. The japanese you hear from anime shows is very informal and can be perceived as rude. As a beginner you won’t be able to differiate between proper and inproper langugae. Not only that, it’s hard to actually pick up vocabulary when you don’t have a basis in the language. There have been studies on this topic, generally you need to know a few thousand words before you will start picking up the language by context.
Use anime and manga as a supplement not as a main learning resource
There are some that swear by just using japanese immersion to learn and completely staying away from formal education. One example that is often used is to watch anime and read manga and you will be able to pick up the language. I strongly disagree, only watching anime on its own is not enough. There might some extreme statistical anomalies who learned japanese from only watching japanese anime and never picked up text book but for the most part I call bullshit on these claims and I’ve yet to actually meet anyone in real life who learned japanese this way. However, i’m not disagreeing that you can use it as a learning tool.
The opportunity cost of watching anime or reading manga
Assume you have the basics down, you will definitely benefit from watching anime but as most things in life you should always take opportunity cost into consideration. Watching anime or reading manga is just not nearly as effective as plain studying. 10 hours spent watching anime will yield in a lot less new vocabularly than studying japanese from textbooks. Watching anime however doesn’t require as much mental energy. If you’re anyway going to watch anime because you enjoy it then it’s a double win. You will learn new stuff while enjoying yourself but if the sole purpose of consuming anime or manga is to learn japanese I would advise against it – not because you won’t learn anything but because pretty much any other learning method is going to give you more return on your time.
The advantages of learning japanese via anime and manga
With manga you will get a nice repeition on the japanese writing system. If you’re reading manga targeting children, you will repeat katakana and hiragana and if you’re reading more mature manga you will get used to reading kanji over and over again solidifying them into your memory. With anime you will get used to hearing japanese and this is very important especially if you’re learning japanese outside of Japan. One of the main struggles with learners outside of Japan is that they almost always seem to lack in the hearing department. The hearing section on the JLPT test is usually the hardest one for learners outside Japan, so watching anime might be a good supplement when you want to do light studying.
How to benefit from it
Ideally you should watch anime with english subtitles if your japanese isn’t up to par. If your japanese is decent, then using original japanese subtitles is more effective as you will also pick up the kanji. Now, luckily it’s far easier to follow an anime than a regular TV drama. The language used in animes tend to be a bit easier and the same vocabularly gets repeated often. I would avoid watching anime that you don’t really like as you will quickly get bored, I would say have to mindset of enjoying yourself rather than “I’m studying”. The latter will quickly turn into grind and you will start loathing it in no time.
So the final verdict is that yes you can learn japanese from watching anime or reading manga but it doesn’t have the highest return on your time. It’s a fun way to relax and still learn something but it should never be your main way of learning.