title: How to avoid pushing duplicates into array
body: <p>How do I make sure that when I'm pushing a new node that, if it is already there then it would not be pushed, otherwise push it. </p>
  
  <pre><code>function defineGraph(edges){
    // Define the graph
    var graph = { nodes: Object.create(null) };
  
    // Define nodes and edges
    graph.nodes = []
    graph.edges = []
  
    // Add content to graph.nodes and graph.edges
    edges.forEach(function (edge) {
      var [f, labels, t, att] = edge;
      graph.nodes.push({label: f, attributes: att})
      graph.nodes.push({label: t, attributes: []})
  
      graph.edges.push([f, t, [labels]])
    });
  
    return graph; }
  </code></pre>
  
  <p>If, it should be of any help my output format is JSON. For example,</p>
  
  <pre><code>"nodes": [
    {
       "label": "a",
       "attributes": [
          "initial"
       ]
    }, {...}
  </code></pre>