summaryrefslogtreecommitdiff
path: root/t.js
diff options
context:
space:
mode:
authorGeo Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2024-11-25 19:44:14 +0200
committerGeo Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2024-11-25 19:44:14 +0200
commit8c27075aea4c6e1d4f81d77f9e833c24e37eeb54 (patch)
tree37b624c5027d9d486102f5cb7e314d05efec5bf1 /t.js
parentd49fd7b4ec7b1ae18bff1d9164906004de7e467e (diff)
downloadslidetray-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.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/t.js b/t.js
new file mode 100644
index 0000000..0b19957
--- /dev/null
+++ b/t.js
@@ -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