title: Function to match Html Element against a given object
body: <p>I'm new to javascript and newer to es6, so the worst possible combination, but please don't give up!</p>
  
  <p>I want to build a function that compares an html element with an object and returns a callback.</p>
  
  <p>The object will be something like:</p>
  
  <pre><code>const Models = {
      button1: {
          nodeName: 'BUTTON',
          className: /save/.test(element.className),
          action: 'save'
      },
      input1: {
          nodeName: 'INPUT',
          dataset: {validate: true},
          action: 'validate'
      },
      select1: {
          nodeName: 'SELECT',
          type: 'SELECT-ONE',
          action: 'whatever'
      }
  }
  
  Models.getAction = function(element) {
      for (let model in Models) {
          // do the magic seomething like:
          if (model.nodeName === element.nodeName /* &amp;&amp; condition 2 for the variable second property*/) {
              return model.action;
          }
      }
  }
  </code></pre>
  
  <p>The example is random, the important part is that the model will have for the first two properties a valid html element property name and their values can be either string, array, or function. I'm not sure about the structure of the object, any correction is welcome. So, in fact, it is necessary to somehow validate the first two properties of the model. The question is what the second condition is gona be, or if there are different ways to achieve the same result.</p>
  
  <p>Thanks in advance.</p>