IsNull equivalent in ASP/jScript

hey folks

i usually code in VBscript and use IsNull - i understand the function does not exist in Jscript. what can be used instead?

(i am checking a database value - but its a general question too)

thanks!
kneidelsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BardobraveCommented:
Js has better aproach to Null management that VB in general lines... usually you cant evaluate a null value in VB, however, in Js a Null value can be evaluated to False without getting errors, this is because in Js all that is not True is always False, as Null can't be True it's automatically set to False when evaluated.

Also you can use a statement like (object == null) if you are not used to evaluate directly an object
0
kneidelsAuthor Commented:
thanks
wasnt sure exactly what you meant
i landed up using the length which seemed to help.

should that give the same indication?
0
Göran AnderssonCommented:
Checking the length would give you the same result for a null value and an empty string value, so that would only work for data types where only a null value is converted into an empty string and no other value. I.e. it would work for a numerical field, but not a text field.

You should be able to determine if a field contains null from it's status:

if (rs["field"].Status == adFieldIsNull) ...

If you don't have the ad constants defined, this one has the value three:

var adFieldIsNull = 3;

-

Checking a null value is different for a database result and null object refereces. A recordset doesn't use null references to represent null values from the database, instead a special Null object is used.

A null reference can easily be determined in JScript using the comparison (obj == null), which is equivalent to IsNothing(obj) in VBscript.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kneidelsAuthor Commented:
great - thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.