javascript export functions code example

Example 1: javascript import class

//import it
import Example from './file2';
//Create an Instance
var myInstance = new Example()
myInstance.test()

Example 2: js class export

export class ClassName {...}

Example 3: export function javascript

// export a function in javascript
export function myFunc(var1, var2, ..., varn) {
  // do something
}

Example 4: export function javascript

// module "mon-module.js"
export default function cube(x) {
  return x * x * x;
}

Example 5: exporting functions

//myfile.js
export function fn1() {...} 
export function fn2() {...} 
import * as MyFn from blabla
                       myFn.fn1();

Tags:

Misc Example