OA. free
Free
MathWorks Core Computer Science Core Computer Science Medium

33.

MathWorks technical mcq question, verified with a worked answer. Free to practise - no sign-up.

Which of the following is considered an object in Javascript?**

Which of the following is considered an object in Javascript?

Pick ONE OR MORE options

Choose one option.
Show answer & explanation
Answer: A. function

In JavaScript, functions are first-class objects—they can be assigned to variables, passed as arguments, and have properties and methods. The primitives (true, 10, string) are not objects; they are primitive values. However, JavaScript automatically wraps primitives in their object counterparts (Boolean, Number, String) when methods are called on them, but the primitives themselves are not objects.

Step-by-step Derivation:
JavaScript distinguishes between primitives and objects. Primitives include: boolean (true/false), number (10), string ('hello'), null, undefined, symbol, and bigint. Objects include: plain objects {}, arrays [], functions function(){}, and Date, RegExp, etc. Functions are callable objects with properties like 'length' and 'name'. Example: typeof function(){} === 'function' (object type), typeof true === 'boolean' (primitive), typeof 10 === 'number' (primitive), typeof 'string' === 'string' (primitive). Therefore, only function is an object.