> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript object

The `object` type in TypeScript represents any non-primitive value. It acts as a strict type constraint enforcing that a value is not a JavaScript primitive (`string`, `number`, `boolean`, `symbol`, `null`, `undefined`, or `bigint`).

Because arrays, functions, and class instances are technically objects in JavaScript, they all satisfy the `object` type constraint.

```typescript theme={"dark"}
let nonPrimitive: object;

// Valid assignments (Non-primitives)
nonPrimitive = {};
nonPrimitive = { key: "value" };
nonPrimitive = [1, 2, 3];
nonPrimitive = () => "function";
nonPrimitive = new Date();

// Invalid assignments (Primitives)
nonPrimitive = 42;        // Error: Type 'number' is not assignable to type 'object'
nonPrimitive = "string";  // Error: Type 'string' is not assignable to type 'object'
nonPrimitive = true;      // Error: Type 'boolean' is not assignable to type 'object'
nonPrimitive = null;      // Error: Type 'null' is not assignable to type 'object'
```

## Property Access Limitations

The `object` type is structurally opaque regarding custom properties. While it guarantees the value is a non-primitive, it provides no information about the object's specific shape. Attempting to access custom properties on a variable typed strictly as `object` will result in a compiler error.

However, variables of type `object` are not completely inaccessible. TypeScript permits access to properties and methods inherent to all JavaScript objects via `Object.prototype` (such as `.toString()`, `.valueOf()`, and `.hasOwnProperty()`).

```typescript theme={"dark"}
let user: object = { name: "Alice", age: 30 };

// Valid: Methods exist on Object.prototype
console.log(user.toString());
console.log(user.hasOwnProperty("name"));

// Error: Property 'name' does not exist on type 'object'.
console.log(user.name); 
```

## Type Distinctions: `object` vs `Object` vs `{}`

A critical technical distinction in TypeScript is the difference between the lowercase `object`, the uppercase `Object`, and the empty object literal `{}`.

* **`object` (Lowercase):** Strictly represents non-primitives. It rejects all primitive values.
* **`Object` (Uppercase):** Describes the functionality common to all JavaScript objects (methods like `toString()` and `hasOwnProperty()`). Because JavaScript auto-boxes primitives (wrapping them in their object equivalents like `String` or `Number`), `Object` accepts primitives.
* **`{}` (Empty Object Type):** Represents an object with no known properties. Structurally, it behaves almost identically to `Object` and also accepts primitive values.

```typescript theme={"dark"}
let strictObject: object;
let globalObject: Object;
let emptyObject: {};

// Assigning a primitive
strictObject = "test"; // ERROR: Type 'string' is not assignable to type 'object'.
globalObject = "test"; // VALID: 'string' has Object.prototype methods.
emptyObject = "test";  // VALID: 'string' satisfies the empty shape.

// Assigning null/undefined (assuming strictNullChecks is true)
strictObject = null;   // ERROR
globalObject = null;   // ERROR
emptyObject = null;    // ERROR
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor TypeScript Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
