jQuery check if Cookie exists, if not create it

I think the bulletproof way is: if (typeof $.cookie(‘token’) === ‘undefined’){ //no cookie } else { //have cookie } Checking the type of a null, empty or undefined var always returns ‘undefined’ Edit: You can get there even easier: if (!!$.cookie(‘token’)) { // have cookie } else { // no cookie } !! will turn … Read more

Equivalent of SQL ISNULL in LINQ?

Since aa is the set/object that might be null, can you check aa == null ? (aa / xx might be interchangeable (a typo in the question); the original question talks about xx but only defines aa) i.e. select new { AssetID = x.AssetID, Status = aa == null ? (bool?)null : aa.Online; // a … Read more

MySQL comparison with null value

In MySQL, NULL is considered as a ‘missing, unknown value’, as opposed to no value. Take a look at this MySQL Reference on NULL. Any arithmetic comparison with NULL does not return true or false, but returns NULL instead., So, NULL != ‘C’ returns NULL, as opposed to returning true. Any arithmetic comparison with ‘NULL’ … Read more

Using ISNULL vs using COALESCE for checking a specific condition?

This problem reported on Microsoft Connect reveals some differences between COALESCE and ISNULL: an early part of our processing rewrites COALESCE( expression1, expression2 ) as CASE WHEN expression1 IS NOT NULL THEN expression1 ELSE expression2 END. In [this example]: COALESCE ( ( SELECT Nullable FROM Demo WHERE SomeCol = 1 ), 1 ) we generate: … Read more

is_null($x) vs $x === null in PHP [duplicate]

There is absolutely no difference in functionality between is_null and === null. The only difference is that is_null is a function and thus is marginally slower (function call overhead) can be used as a callback, e.g. array_map(‘is_null’, $array). Personally, I use null === whenever I can, as it is more consistent with false === and … Read more