Skip to content

Commit fd592e3

Browse files
committed
Define calculated fields methods and example
1 parent 0867baa commit fd592e3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

JavaScript/a-calculated.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
// Usage
4+
5+
const data = { name: 'Marcus Aurelius', born: 121, city: 'Rome' };
6+
7+
const cities = {
8+
'Roman Empire': ['Rome']
9+
};
10+
11+
const [obj, transaction] = Transaction.start(data, {
12+
age() {
13+
return (
14+
new Date().getFullYear() -
15+
new Date(this.born + '').getFullYear()
16+
);
17+
},
18+
country() {
19+
// implementation cann access cities index
20+
}
21+
});
22+
23+
console.dir({ age: obj.age, country: obj.country });

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy