Jump to content

Affect of NULL Type in Coding


j.silver

Recommended Posts

It's not really a bug, it's actually designed that way in the specification: http://www.ecma-international.org/ecma-262/5.1/#sec-11.4.3

 

My first recommendation would be to not use the typeof operator. You might think you need it, but there probably is a better way to design your software. If you show me the code where you need it I can find out how to write the code without it.

Link to comment
Share on other sites

Null is usually the value you assign to a variable if it's meant to contain an object but does not have one yet. You can set a variable to null in order to remove a reference to an object and free memory.

Link to comment
Share on other sites

Having NULL type as an object to be a bug in js, is there any harm to code this could result in, and what precautions should we take to avoid such harm?

 

Null is commonly used to indicate that a variable or object is invalid, so it is not a bug, but it may indeed indicate that your code isn't working.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...