> ## 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.

# JavaScript Namespace Import

A namespace import is an ECMAScript module (ESM) syntax that gathers all exported bindings from a specified module and attaches them as properties to a single, locally scoped object. This mechanism creates a **Module Namespace Exotic Object**, allowing access to a module's entire exported API surface through a single identifier.

## Syntax

```javascript theme={"dark"}
import * as namespaceIdentifier from "module-specifier";
```

* `*`: Represents all named and default exports from the target module.
* `as namespaceIdentifier`: Binds the imported Module Namespace Object to a local variable name.
* `module-specifier`: The string literal path to the module.

## The Module Namespace Object

The object created by a namespace import is not a standard JavaScript object literal. It is a specialized exotic object with strict internal behaviors:

1. **Live Bindings:** Properties on the namespace object maintain a live connection to the exported variables in the source module. If the source module mutates an exported value, the namespace object immediately reflects that change.
2. **Property Attributes & Assignment:** Exported bindings are exposed as data properties with `writable: true`. This is required to satisfy core JavaScript object invariants, as the values can change over time via live bindings. However, the object utilizes a custom `[[Set]]` internal method that always returns `false`. Because ES modules execute in strict mode, attempting to reassign a property throws a `TypeError`.
3. **Extensibility:** The namespace object is non-extensible (`Object.isExtensible()` returns `false`) and sealed (`Object.isSealed()` returns `true`). It is *not* frozen (`Object.isFrozen()` returns `false` if the module has at least one export) because its exported data properties report `writable: true`.
4. **Null Prototype:** The object inherits from nothing. Evaluating `Object.getPrototypeOf(namespaceIdentifier)` returns `null`.
5. **Default Export Handling:** If the source module contains a `default` export, it is exposed on the namespace object under the explicit property key `default`.
6. **Symbol.toStringTag:** The object has a built-in `[Symbol.toStringTag]` property with the string value `"Module"`.

## Mechanical Example

**Source Module (`source.js`):**

```javascript theme={"dark"}
export let counter = 0;
export function increment() { counter++; }
export default class Core {}
```

**Importing Module (`main.js`):**

```javascript theme={"dark"}
import * as SourceAPI from './source.js';

// Accessing named exports
console.log(SourceAPI.counter); // 0

// Demonstrating live bindings
SourceAPI.increment();
console.log(SourceAPI.counter); // 1

// Accessing the default export
const coreInstance = new SourceAPI.default();

// Prototype and internal characteristics
console.log(Object.getPrototypeOf(SourceAPI)); // null
console.log(Object.prototype.toString.call(SourceAPI)); // "[object Module]"
console.log(Object.isSealed(SourceAPI)); // true
console.log(Object.isFrozen(SourceAPI)); // false

// Immutability enforcement
SourceAPI.counter = 100; // TypeError: Cannot assign to read only property
SourceAPI.newProp = 'API'; // TypeError: Cannot add property newProp, object is not extensible
```

<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 JavaScript 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>
