Skip to content

Instantly share code, notes, and snippets.

View gpDA's full-sized avatar
🏠
Working from home

GP LEE gpDA

🏠
Working from home
View GitHub Profile
// TableUI.js
return(
<React.Fragment>
<Table>
<thead>
<tr>
<th onClick={() => handleSortClick("studentId")}>
<strong>
studentId
// store/modules/base.js
// initial state
const initialState = Map({
mainData: List([
{
studentId: "1",
studentName: "Jim",
studentAge: 0,
studentZipCode: "N/A"
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
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";
};
}
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 () {
elem.addEventListener(..., {capture: true})
// or, just "true" is an alias to {capture: true}
elem.addEventListener(..., true)
<div id="div1">I am a div1</div>
<script>
const div1 = document.getElementById("div1");
div1.addEventListener("click", function() {
console.log("div1 clicked");
});
</script>
<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");
});
function handleClick(event) {
event.stopPropagation();
// do something
}
const body = document.getElementsByTagName('body')[0];
function callback() {
console.log('Hello');
}
body.addEventListener('click', callback);