Message from JavaScript discussions

November 2020

— Dunno, I have the canary version, could still be in beta


I have an operator in a string as below:
let operator = "<"; //could also be ==, >, < etc
now I want to compare using this operator like:
if(foo operator bar){

How do i do it

— Random pool generator toy:


a = if operator == '<'
then a < b
else if operator == '>'
then a > b
else a == b
#livescript pseudocode

Message permanent page

— Thanks for your response. Could you please explain how it works?

— It works straight away.. ternary, switch or ifs, you decide

— This is my current solution

— Why you need Operators.blabla

— Too many entry points will weaken the fortress

— It is a filter function where it accepts
valueInArray to compare
Operand - how to compare // ==, <, > etc
Value to compare with.

Message permanent page

— So you do
[{a: 2}, {a: 3}, {a:4}].filter('a', 'gt', 3);
the return is: [{a:4}]

— Don't over-engineer things, or you'll fall into random trap🤤