Asked 7 days ago
14 Jan 2017
Views 252

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 ?

answered Jan 21 '18 20:17

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

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
Edit Answer
Post Answer