Example 1 — Default import
import Name from "./mod.js".
JavaScript
console.log("import App from './app.js'"); How It Works
- Local name is your choice.
import brings bindings from another module. Named imports must match export names (or use as). Default imports choose any local name.
// Conceptual: import { PI } from "./math.js";
const PI = 3.14; // stand-in for imported binding
console.log(PI); import Name from "./mod.js".
console.log("import App from './app.js'"); import * as mod from ...
console.log("import * as math from './math.js'"); import "./init.js".
console.log("import './polyfill.js'"); CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
6 people found this page helpful