import filename Last updated: 18. Jul 2023

Keyword

The `import` keyword in JavaScript is used to import functions, objects, or variables from another file, which can then be used in the current file.

Parameters

Name Type Description
filename string Absolute path to file to iinclude.

Returns

null

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
// Import code from other file
import "#/test-import.js";

// Run imported function
test();

Output

The JS code above produces the output shown below:
Test function called!