diff --git a/src/services/playground2.js b/src/services/playground2.js new file mode 100644 index 0000000..ad56039 --- /dev/null +++ b/src/services/playground2.js @@ -0,0 +1,19 @@ +var predicates = { + '==': function (a, b) { + return a === b; + }, + '>=': function (a, b) { + return a >= b; + }, + '<': function (a, b, item) { + return item[a] < item[b]; + }, +}; +let p = predicates['<']; +let item = { + a: 1, + b: 2, +}; +console.log(item['a'], item['b']); +console.log(item['a'] < item['b']); +console.log(p('a', 'b', item));