Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //modules_o1.html
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script type="module" src="./modulo.js"></script>
- <script type="module" src="./modulo2.js"></script>
- <script>
- alert(this);
- //import {coefficiente, metodoPubblico} from './modulo.js';
- //import * as M1 from './modulo.js';
- //import coefficiente from './modulo.js';
- //import {coefficiente as coeff, metodoPubblico as metodo1, ditta, getDitta, obj, getObj} from './modulo.js';
- // alert(coeff);
- // metodo1();
- //ditta = "Rockerduck inc."; NO, READ ONLY!
- //getDitta();
- //obj.desc = "ventola";
- // alert(obj.desc);
- // getObj();
- //obj = {}; //NO, READ ONLY!
- </script>
- </body>
- </html>
- //modulo.js
- //parte pubblica
- export const coefficiente = 1.2;
- //export default coefficiente;
- export let ditta = "ACME spa";
- export let numero=300;
- export function metodoPubblico() {alert('metodo pubblico invocato');}
- export function getDitta() {alert(ditta);}
- export let obj = {id: 123, desc: 'scheda video'};
- export function getObj() {alert(obj.desc);}
- // parte privata
- const privata = 35;
- function fprivata() {alert('io sono privata');}
- //alert(x);
- //modulo2.js
- let x = 100;
- //alert(this);
- //occhio: aspettatevi problemi con CORS policy (vedere i video su asynchronous javascript per una completa e corretta gestione)
- let ris = await fetch('http://dog-api.kinduff.com/api/facts?number=5');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement