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
list = { | |
name: 'yukee' | |
} | |
// ES5 | |
this.state = { | |
list: list, | |
}; | |
// ES6 | |
this.state = { |
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
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import './index.css'; | |
import App from './App'; | |
ReactDOM.render( | |
<App />, | |
document.getElementById('root') | |
); |
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
// remove index-1 position component of array without modify the origin array | |
list = [1, 2, 3, 4, 5] | |
const removeCounter = (list, index) => { | |
return [ | |
...list.slice(0, index), | |
...list.slice(index + 1) | |
]; | |
} | |
removerCounter(list, 3); //[1, 2, 4, 5]; |
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 createStore = (reducer) => { | |
let state; | |
let listeners = []; // an array of listeners | |
const getState = () => state; | |
const dispatch = (action) => { | |
state = reducer(state, action); | |
listeners.forEach(listener => listener()); // to notify every change listener by calling it | |
}; |
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
// pipe function: A pipe function takes an n sequence of operations; in which each operation takes an argument; | |
// process it; and gives the processed output as an input for the next operation in the sequence. The result of a | |
// pipe function is a function that is a bundled up version of the sequence of operations. | |
//======= two functions in pipe function ========= | |
const pipe = (op1, op2) => { | |
return (arg) => { | |
const result1 = op1(arg); | |
return op2(result1); | |
} | |
} |
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
/* let dog = { | |
sound: 'woof', | |
talk: function(){ | |
console.log(this.sound); | |
} | |
} | |
const Talk = dog.talk.bind(dog); | |
Talk(); */ |
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
var express = require("express"), | |
mongoose = require("mongoose"), | |
bodyParser = require("body-parser"), | |
User = require("./models/user"), | |
passport = require("passport"), | |
LocalStrategy = require("passport-local"), | |
passportLocalMongoose = require("passport-local-mongoose"); | |
mongoose.connect("mongodb://localhost:27017/auth_demo_app", { useNewUrlParser: true }); | |
var app = express(); |
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
var mongoose = require("mongoose"); | |
mongoose.connect("mongodb://localhost:27017/blog_demo", { useNewUrlParser: true }); | |
// POST - title, content | |
var postSchema = new mongoose.Schema({ | |
title: String, | |
content: String | |
}); | |
var Post = mongoose.model("Post", postSchema); |
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
#main_container{ | |
margin-top: 7.0em; | |
} | |
#delete{ | |
display: inline; | |
} |
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
var mongoose = require("mongoose"); | |
mongoose.connect("mongodb://localhost/food_app"); | |
var foodSchema = new mongoose.Schema({ | |
name: String, | |
taste: String, | |
isGood: Boolean, | |
price: Number | |
}); |
NewerOlder