TypeScript Types
object — non-primitive type
The lowercase object type excludes primitive values. Arrays, functions and ordinary objects are assignable to it. It does not declare application-specific fields, so a function that accepts object cannot assume a name or id property. Use a structural object type to require known members. Under strict null checking, null and undefined are excluded. Example output: "array". The example was designed for strict checking with an ES2022 target; type annotations do not add runtime validation.
Formal Syntax & Structure
typescript syntaxtypescript
let value: object;Working Example
Example Snippettypescript
function accept(value: object): string { return Array.isArray(value) ? "array" : "other object";}console.log(accept([]));