Which of the following code snippets will correctly get the length of an object?
Answer
Correct Answer: <script> var newObj = new Object(); newObj["firstname"] = "FirstName"; newObj["lastname"] = "LastName"; newObj["age"] = 21; Object.size = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(key)) size++; } return size; }; var size = Object.size(newObj); </script>
Explanation:
Note: This Question is unanswered, help us to find answer for this one