And yet they're the easiest exceptions to avoid. It's actually pretty much programming 101: 1) don't return null, and/or 2) check to make sure it's not null before you do something that can throw an NPE.
var element = null;
element.getAttribute("id");
// crash
-4
u/yogazook Jun 28 '16
And yet they're the easiest exceptions to avoid. It's actually pretty much programming 101: 1) don't return null, and/or 2) check to make sure it's not null before you do something that can throw an NPE.
Yeah, no shit.