diff options
| author | Geo Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2024-11-25 19:44:14 +0200 |
|---|---|---|
| committer | Geo Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2024-11-25 19:44:14 +0200 |
| commit | 8c27075aea4c6e1d4f81d77f9e833c24e37eeb54 (patch) | |
| tree | 37b624c5027d9d486102f5cb7e314d05efec5bf1 /t.js | |
| parent | d49fd7b4ec7b1ae18bff1d9164906004de7e467e (diff) | |
| download | slidetray-8c27075aea4c6e1d4f81d77f9e833c24e37eeb54.tar.gz slidetray-8c27075aea4c6e1d4f81d77f9e833c24e37eeb54.tar.bz2 slidetray-8c27075aea4c6e1d4f81d77f9e833c24e37eeb54.zip | |
impelement requirejs demo; introduce esm demo
Diffstat (limited to 't.js')
| -rw-r--r-- | t.js | 50 |
1 files changed, 50 insertions, 0 deletions
@@ -0,0 +1,50 @@ + +const personFactory = (setup) => { + + let person = { + + who: { + // name: '', + // surname: '', + // age: 0, + // job: 'unpemployed' + }, + + init: function (json) { + // this.who.name = json.name; + // this.who.surname = json.surname; + // this.who.job = json.job; + // this.who.age = json.age; + this.who = json; + return this; + }, + + whoami: function() { + let who = this.who; + return `${who.name} ${who.surname}, ${who.job}, ${who.age} years old`; + }, + + setJob: function (job) { + this.who.job = job; + return this; + }, + + grow: function(years) { + if (years == null) this.who.age++; + else this.who.age += years; + return this; + } + + } + + return person.init(setup) + +} + +geo = personFactory({ + name: 'George', surname: 'Xalkis', age: 56 +}) +console.log('@@init', geo.whoami()); + +geo.setJob('developer').grow(4); +console.log(geo.whoami());
\ No newline at end of file |
