JSFiddle - React, Tailwind, and code Playground

by Alexander Branchugov

JavaScript

function checkCondition(expression, data) {
  return (function () {
  console.log(this)
    try {
      return eval(expression);
    } catch (e) {
      return false;
    }
  }).call(data);
}

var expression = 'this.a === 1';
var data = {a: 2};

console.log(checkCondition(expression, data))