TypeScript · Middle · Question 25 of 75
How do object, {} and Record<string, unknown> differ as types?
- ✓Correct answer:
{}- anything non-null,object- non-primitive,Record- a dictionary - 2They're three synonyms for "any object" in TypeScript
- 3
{}means only an empty object without a single property
Explanation
{} accepts strings and numbers too - everything except null and undefined, which often surprises people. object excludes primitives. Record<string, unknown> is an object with arbitrary string keys whose values you can access. For "any value", unknown is better.