This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // TableUI.js | |
| return( | |
| <React.Fragment> | |
| <Table> | |
| <thead> | |
| <tr> | |
| <th onClick={() => handleSortClick("studentId")}> | |
| <strong> | |
| studentId |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // store/modules/base.js | |
| // initial state | |
| const initialState = Map({ | |
| mainData: List([ | |
| { | |
| studentId: "1", | |
| studentName: "Jim", | |
| studentAge: 0, | |
| studentZipCode: "N/A" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const compareBy = key => { | |
| return function(a, b) { | |
| if (sortToggle) { | |
| if (a[key] == null || a[key] == 0 || a[key] == "N/A") return 1; | |
| if (b[key] == null || b[key] == 0 || b[key] == "N/A") return -1; | |
| if (a[key] < b[key]) return -1; | |
| if (a[key] > b[key]) return 1; | |
| return 0; | |
| } else { | |
| // descneding |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Car(model, year, miles) { | |
| this.model = model; | |
| this.year= year; | |
| this.miles = miles; | |
| this.toString = function () { | |
| return this.model + " has done " + this.miles + " miles"; | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Car(model, year, miles) { | |
| this.model = model; | |
| this.year = year; | |
| this.miles = miles; | |
| } | |
| // Note here that we are using Object.prototype.newmethod rather than | |
| // Object.prototype so as to avoid redefining the prototype object | |
| Car.prototype.toString = function () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| elem.addEventListener(..., {capture: true}) | |
| // or, just "true" is an alias to {capture: true} | |
| elem.addEventListener(..., true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div id="div1">I am a div1</div> | |
| <script> | |
| const div1 = document.getElementById("div1"); | |
| div1.addEventListener("click", function() { | |
| console.log("div1 clicked"); | |
| }); | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div id="div1"> | |
| <div id="div2">I am a div1</div> | |
| </div> | |
| <script> | |
| const div1 = document.getElementById("div1"); | |
| div1.addEventListener("click", function() { | |
| console.log("div1 clicked"); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function handleClick(event) { | |
| event.stopPropagation(); | |
| // do something | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const body = document.getElementsByTagName('body')[0]; | |
| function callback() { | |
| console.log('Hello'); | |
| } | |
| body.addEventListener('click', callback); |