javascript - How to exit / return from class as null -
usually in other languages looks nullreferenceexception, don't know how in js, beginner knowledge of c# - not js
<script> var x = new fooclass(null); function fooclass(foo) { if(foo===null) return; // return type "fooclass" // want return tell // class wrong initialized, maybe exception? alert(foo); // show script continues } </script>
yes. exactly. can throw exception stating error message
if(foo === null) throw "null not allowed" // throw exception message
Comments
Post a Comment