- Closure
- closure function can access
- innver variable
- outer variable
- global variable
123456789function outerFn() {let outerVar = 'outer';function innerFn(){let innerVar = 'inner';console.log(outerVar);console.log(globalVar);}return innerFn;}let globalVar='global';
cs
- Currying
- a process of taking function with multiple arguments into a sequence of nesting function
- parameter will be fixed
12345678function multiply(x) {return function(y) {return x * y;}}multiply(3)(4); // 12let multiply10 = multiply(10);multiply(7); // 70
cs 12345678910111213function htmlMaker(tag) {let startTag = '<' + tag + '>';let endTag = '</' + tag + '>';return function(content) {return startTag + content + endTag;}}let divMaker = htmlMaker('div');divMaker('Paige'); // <div>Paige</div>let spanMaker = htmlMaker('span');spanMaker('Paige'); // <span>Paige</span>cs
- Module Pattern
- assign variable inside closure not to be changed
- each function will not affect each other
12345678910111213141516171819202122232425262728function calculate() {let insideCalculate = 0;let obj = {increment: function() {insideCalculate ++;},decrement: function() {},getValue: function() {return insideCalculate;}};return obj;}let one = calculate();one.increment();one.increment()lone.getValue(); // 2insideCalculate; // reference errorlet two = calculate();two.increment();two.increment();two.increment();two.increment();two.increment();two.decrement();two.getValue(); // 5
cs
- closure function can access
COMMAND LINE INTERFACE(CLI)
- Pros
- fast and powerful
- good for accesibility
- command
CHECK | |
ls | list what is inside directory |
ls -al |
list detail |
MOVE DIRECTORY | |
cd | change directory(directory = folder) cd Downloads |
pwd | print work directory show full path of current directory |
cd ~ | home directory |
cd / | root directory 최상위 디렉토리 |
cd . | current directory |
cd .. | parent directory |
clear | clear |
tab | autocomplete |
CREATE | |
\ | need to put in order to space My\ Documents |
touch | create file touch newfile.txt |
mkdir | make directory mkrdir newdir |
MOVE | |
mv | move document mv newfile.txt newdir(move txt inside newdir) change file or directory name mv newfile.txt newname.txt |
CHECK FILE | |
cat | check text file |
COPY | |
cp | copy file cp newname.txt ~/Downloads/ |
cp -r | copy folder |
DELETE | |
rm | delete file does not ask whether i will delete or not and not even go to trash rm newname.txt |
rm -r / rm-rf | delete folder |
SUDO (Super User Do) |
|
touch | make file sudo touch testfile.txt |
chown | change owner sudo chown paige:staff testfile.txt |
CLI PROGRAM | |
vim | vim testfile.txt reference: github.com/yuanqing/vim-basics/blob/master/README.md |
- What you do @ GUI === What you do @ CLI
GIT
Version control system
- Strong versions
- Restoring prvious versions
- Understanding what happened
- Collaboration
- Backup
Features
- Branching and merging
- Distributed
- Data assurance
- Staging area
DISTRIBUTED
- Local Repository: in my own computer
- fork: copy from Git remote repository
- clone: bring into local repository
- if something changes at local repository,
- use 'git push origin master'(my repository)
- if something changes at origin or remote repository
- origin: use 'git pull origin master'
- upstream: use 'git pull upstream master'
- Staging Area
- working directory --(git add index.html)-->staging area--(git commit)-->repository
- Commit
- use 'git commit -m "Add headline to index page"'
- always need to add message to identify what has been chaged
- use 'git commit -m "Add headline to index page"'
- Branching & Merging
- Branching: allow each developers to work seperately
- Merging: allow each developers to merge what they make
- Master branch: code that will released to users(no bug)
- Develop branch: includes codes that is middle of development and need to go through test and bug fix
- feature branch: includes each function
'TIL' 카테고리의 다른 글
TIL 2020.11.06 (0) | 2020.11.06 |
---|---|
TIL 2020.11.05 (0) | 2020.11.05 |
TIL 2020.11.03 (0) | 2020.11.03 |
TIL 2020.11.02 (0) | 2020.11.02 |
TIL 2020.11.01 (0) | 2020.11.01 |