Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Exporting And Importing From A Module

/*test.js*/
const add = (x, y) => {
    return x + y
}

const subtract = (x, y) => {
    return x - y;
}
var a = "a";
var b = "b"; 
export {a, b, subtract, add}

/*index.ejs*/


<script type="module">  
	import {add, subtract, a} from '/javascripts/test.js';
	window.onload = function()
	{
	console.log(add(2, 3));
	console.log(subtract(6,3));
	console.log(a);
	}
	</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: react state based router 
Javascript :: jquery search button 
Javascript :: Importing Ky Module In JavaScript 
Javascript :: Uncaught Error: spawn node 
Javascript :: code with mosh swipable react native not working 
Javascript :: phaser reverse matrix columns 
Javascript :: javascript object access time complexity 
Javascript :: Gamification Details Component is not declared in any Angular module 
Javascript :: what is setImmediate vs clearImmediate 
Javascript :: how to chaage background color of any element from java script 
Javascript :: A Node Module For ReactJS 
Javascript :: phaser add camera 
Javascript :: cannot setState in event handler 
Javascript :: how to display unicode in javascript 
Javascript :: checkbox null value javascript 
Javascript :: Turn A 2D Array Into A JSON 
Javascript :: add text to each element in an array javascript 
Javascript :: how to store new object made by constructor classes data in local storage using javascript 
Javascript :: use function in mongodb query example 
Javascript :: Backbone View El 
Javascript :: Backbone With Express 
Javascript :: Check if a number starts with another number or not js 
Javascript :: Solution-2--solution options for reverse bits algorithm js 
Javascript :: var date = new Date(); 
Javascript :: javascript add button 
Javascript :: why null is object in javascript 
Javascript :: jsx attributes 
Javascript :: date.setdate javascript 
Javascript :: adonisjs char 
Javascript :: javascript DOM SELECT 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =