Asked 7 years ago
14 Jan 2017
Views 1990
jassy

jassy posted

import statement in JavaScript

what is use of import statement in JavaScript ?

#import 'libfile'

is import used to load library file in JavaScript ?
how it import work in JavaScript ?

is import work as css : @import cssfile.css in JavaScript ?
Rasi

Rasi
answered Nov 30 '-1 00:00

import statement is not native implemention means you cant use it your browser . you need external library to use import .
external library like
Traceur Compiler, Babel, Rollup or Webpack.

what is import statement ?
import is used to import function or objects or primitives from external modules or another script .

how to use ?
export will define object or function or primitives as importable

---oneFile.js---
export var a='data';


 <script src="ajax.js"></script>
import { a} from "ajax.js";

but it give error now because native browser dont have export or import stantment

Error caused for native browser
Uncaught SyntaxError: Unexpected token export

Uncaught SyntaxError: Unexpected token import
Post Answer