Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <input id="a" type="text">
  <input id="b" type="text">
  <button type="button" id="submit">Submit</button>
  <button type="button" id="view">View results in console</button>
</body>
<script type="text/javascript">
var results = [];
function Example(a, b) {a
  this.a = a;
  this.b = b;
}
function getElements() {
 var a = document.getElementById('a').value;
 var b = document.getElementById('b').value;
 results.push(new Example(a, b));
}
function loopResults() {
  for (var i = 0; i < results.length; i++) {
    console.log(results[i]);
  }
}
document.getElementById('submit').addEventListener('click', getElements, false);
document.getElementById('view').addEventListener('click', loopResults, false);
</script>
</html>
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers