Javascript does not provide isEmpty() method to check object if it is null/empty. However, it does provide a enumerator so we can test object if it at least has one item.
function isEmptyObject(obj) {
for (var key in obj) {
return false;
}
return true;
}
This is a tricky implementation and it does not bring too much performance overhead because the look-break immediately after the first item is tested.
References
1. http://leonax.net/p/7058/check-if-object-is-null-in-javascript/
–EOF (The Ultimate Computing & Technology Blog) —
125 wordsLast Post: How to Call Win32 APIs in C++ code - Quick Tutorial
Next Post: How to Disable Content Output in RSS Feed for WordPress?