This is an old revision of the document!
Javascript Advance and Modules
- as javascript program becomes complex, it has new concepts of modules, (like python module, a library of functions)
- as javascript is inside different browser, means it needs browser support, modern new browser has support new feature of js, but js need to tell them, how modern this JS code is, like type attribute.
<!doctype html> <script type="module"> // note: module need browser access via http, not file:/// import {sayHi} from './say.js'; document.body.innerHTML = sayHi('John'); </script>
other new ES6 codes
- new let vs var
let a = 1 // local block accessible only var b = 1 // global accessible
- unpack assignment (destructuring assignment, as from js1.7 = ES6)
[a, b] = [10, 20]; // Destructuring arrays // same as pyhton: a,b = [10,20] const Zell = { firstName: 'Zell', lastName: 'Liew' } let { a, b} = Zell // destructuring objects
Useful code
- time left countdown (pure js): https://www.codegrepper.com/code-examples/javascript/make+time+left+from+date.now+javascript
- javascript date and timezone: https://flaviocopes.com/javascript-dates/
- time related lib: https://momentjs.com/timezone/
- confetti from tsparticles:
- button click confetti: