Not a recommended way to say the least. But it can be used to supplement your knowledge and it helps you enjoy the process
If you are rather serious about learning through anime though, then you should first pick up the basics from elsewhere then do the translations for the anime yourself. Play a short scene in the raw, translate it the best you can and then compare with a good translation. Rinse and repeat. Write down the words they say - IN JAPANESE - and correct yourself every time. Don't go for full length episodes because learning requires focus. It's imperative that you know Hiragana, Katakana and some Kanji before you start with anime and that you know the basic grammar. Anime helps a lot with vocabulary and such and like I said, helps you enjoy the process, but without rigor, you won't be learning much, if anything