MCQs > IT & Programming > JavaScript > Which 'if' statement is correctly used to get the size of both 'variable1' and 'variable2' objects? var variable1 = {'name':'theName', 'address':'theAddress','age': '18'} var variable2 = ['theName','theAddress','18']; variable1["name"] = "theName2"; variable1["name"] = "theName3"; variable1["name2"] = "theName4"; variable1["name2"] = "theName5"; Object.size = function(importer) { var exporter = 0, key; for (key in importer) { if (importer.hasOwnProperty(key)) exporter++; } return exporter; };

JavaScript MCQs

Which of the following 'if' statements is correctly used to get the size of both 'variable1' and 'variable2' objects? var variable1 = {'name':'theName', 'address':'theAddress','age': '18'} var variable2 = ['theName','theAddress','18']; variable1["name"] = "theName2"; variable1["name"] = "theName3"; variable1["name2"] = "theName4"; variable1["name2"] = "theName5"; Object.size = function(importer) { var exporter = 0, key; for (key in importer) { if (importer.hasOwnProperty(key)) exporter++; } return exporter; };

Answer

Correct Answer: if(typeof(variable1) == typeof(variable2)){ Object.size(variable1); variable2.length; }

Explanation:

Note: This Question is unanswered, help us to find answer for this one

JavaScript Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

JavaScript Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it