Example 1
| The code is as follows |
Copy Code |
if (Tt==null | | tt== "") { Alert ("Kong"); } else { Alert ("Bukong"); } |
Example 2
| The code is as follows |
Copy Code |
The var is = function (Obj,type) { return (type = = "Null" && obj = = null) | | (Type = = "Undefined" && obj = = void 0) | | (Type = = "Number" && isfinite (obj)) | | Object.prototype.toString.call (obj). Slice (8,-1) = = type; } |
Whether an element of an array is empty
1. If an array element does not exist: if (arr[x] = = undefined) determines
2. If the content in the element is null, it needs to be judged by the value of the array you are populating.
| code is as follows |
copy code |
| var B = new Array (1,null, ') Console.log (b[1] = null);//fill element with null value Console.log (b[2] = = ");//Fill element with empty (') value Console.log (b[3] = = undefined); To determine an element that does not exist |