function ConstructorFunction(x) { this.x = value0; this.a = value1; this.b = value2; this.newFunction = function() { //code to be part of the function};
} }
// we use the keyworkd
new
to create a new instance of the construtor function let xxx1 = new ConstructorFunction(); let xxx2 = new ConstructorFunction(); //output would contain the keyworkdConstructorFunction
//create new properties of the constructorFunction for one object variable.newInstance = ‘a string’
create new properties for all objects created, use keyworkd
prototype
ConstructorFunction.prototype.newInstance = ‘a string’
use a for-loop to invoke all student at once let array = [array[0], array[1],array[2]]; //create instances of items to be iterated for (let i=0; i < array.length, i++) {array[i].newFunction()};
more DOM stuff today: xxx.setAtrribute(‘HTML attribute”, value)
<thead>
and <tbody>
and <tfoot>
are used to create an HTML table, must follow the order of Head – Data – Foot, and they all must be children of <tr>
, otherwise browser will re-organize it to such order<table>
– <thead>
, <tbody>
, <tfoot>
–<tr>
– <th>
, <td>
, <tf>
<table>
semantic tags include: <th>
(table headers), <td>
(table data), <tr>
(table row), <colspan>
, <rowspam>
new
key word, such that a new object will be creaetdthis
can be used to bind to the constructor code and refer to itselfexamples of a prototype: I used to have to make chemical models before running the experiment. More basic scientific experiment required me do prototype the reaction on paper, more advanced ones requires programming
documen.querySelector(<any CSS selector>)
https://www.w3schools.com/html/html_tables.asp ↩
https://github.com/codefellows/domain_modeling#domain-modeling ↩
https://developer.mozilla.org/en-US/docs/Learn/HTML/Tables/Basics ↩
https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Basics#introducing_constructors ↩
https://ui.dev/beginners-guide-to-javascript-prototype ↩