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 

more throw on mdn


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -