js container class
function Branches() {
function Branch() {
var _id;
_id = Math.round(Math.random()*10);
this.getId = function() {
return _id;
}
}
this.createBranch = function() {
var branch = new Branch;
_branches.push(branch);
}
this.getBranches = function() {
return _branches;
}
this.getBranchIds = function() {
var branch_list = this.getBranches();
var branch_ids = [];
for (var i = 0; i < branch_list.length; i++) {
var branch_id = branch_list[i].getId();
branch_ids.push(branch_id);
}
return branch_ids;
}
var _branches = [];
}
// code test
var test = new Branches;
for (var i = 0; i < 7; i++) {
test.createBranch();
}
console.log("Branch IDs:\n" + test.getBranchIds());
Also in JavaScript:
- js pixelated
- ajax cdn
- class component react
- jquery doc on ready
- how to convert time to am pm in javascript
- how to deep copy an object in javascript
- react native navigation remove top header screen
- json object length in javascript
- number of edges between set of nodes networkx
- open link in new tab javascript
- Build JavaScript Objects
- set attribute javascript background image
- $post in jquery
- javascript code for year in html
- how to get array from object in javascript
- ajax file upload jquery
- snackbar in react
- modify array js
- javascript array remove middle
- speedtest-net node.js
- vertical align center react native view
- javascript sendredirect
- compiler.js:2175 Uncaught Error: Unexpected value 'undefined' imported by the module 'AppRoutingModule' at syntaxError
- javascript indexOf object value in array