Arguments

  • an Array-like object accessible inside functions that contains the values of the arguments passed to that function.
  • In order to change it to array
    • Array.from(arguments)
  • has length property that can count from index #0 but does not have other methods like array
  • ๋‚ด์žฅ๊ฐ์ฒด ํ•จ์ˆ˜์— ์ „๋‹ฌ ๋œ ์ธ์ˆ˜์— ํ•ด๋‹นํ•˜๋Š” ๋ฐฐ์—ด ํ˜•ํƒœ์˜ ๊ฐ์ฒด
  • ํ•จ์ˆ˜๋ฅผ ์„ ์–ธํ•œ ์ˆœ๊ฐ„, arguments ๊ฐ์ฒด๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์Œ
  • ํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋˜๋Š” ์‹œ์ ์—, ๊ทธ ๋•Œ ์ „๋‹ฌ ๋œ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์ €์žฅํ•œ ๊ณณ
  • ํŒŒ๋ผ๋ฏธํ„ฐ ์ˆซ์ž๋ฅผ ์ •ํ•ด๋†“๋”๋ผ๋„, ์ œํ•œํ•˜์ง€๋Š” ์•Š๊ธฐ์—, ์ ๊ฒŒ ๋„ฃ๊ฒŒ ๋˜๋ฉด undefined๊ฐ€ ๋˜๊ณ  ๊ฐฏ์ˆ˜๊ฐ€ ์ƒ๊ด€์—†์Œ
  • ๋‚ด์žฅ ๋ฉ”์„œ๋“œ๋ฅผ ํฌํ•จํ•˜๊ณ  ์žˆ์ง€ ์•Š์Œ

CSS Selector

  • Grandchildren Selector(ํ›„์† ์…€๋ ‰ํ„ฐ)

    • header h1 {}

  • Child Selector(์ž์‹ ์…€๋ ‰ํ„ฐ)

    • header > p { }

  • Adjacent Sibiling Selector(์ธ์ ‘ ํ˜•์ œ ์…€๋ ‰ํ„ฐ)

    • section + p { }

  • Sibiling Selector(ํ˜•์ œ ์…€๋ ‰ํ„ฐ)

    • section ~ p { }

  • ul > li:nth-child(2n) { }
    • Inside unordered list and list, choose child who is even
  • section > p:nth-child(2n+1) { }
    • Among child elements of section, choose child element p who is odd
  • section > p:nth-last-child(2n + 1) { }
    • Among child elements of section, choose child element p who is odd from the back
  • p:first-of-type { }
    • Choose first p element among its sibiling elements of p
  • div:last-of-type { }
    • choose last div element among its sibiling elements of div
  •  p:nth-of-type(2) { }
    • choose second p element from sibiling elements of p
  • p:nth-last-of-type(2) { }
    • choose second last p element from sibiling elemetns of p
  • p:not(#only) {}
    • choose all except id is only from p elements

'TIL' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

TIL 2020.11.07  (0) 2020.11.07
TIL 2020.11.06  (0) 2020.11.06
TIL 2020.11.04  (0) 2020.11.04
TIL 2020.11.03  (0) 2020.11.03
TIL 2020.11.02  (0) 2020.11.02

Shallow Copying Objects:

  • Will duplicate the top-level properties but nested object is shared between original and the copy
  • Array.prototype.slice()
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    const arr = ['peanut''butter''and''jelly'];
     
    arr.slice(1); // ['butter', 'and', 'jelly']
    arr.slice(01); // ['peanut']
    arr.slice(02); // ['peanut', 'butter']
    arr.slice(22); // []
    arr.slice(220); // ['and', 'jelly']
    arr.slice(30);// []
    arr.slice(3100);// ['jelly']
    arr.slice(51); // []
    cs
  • Object.assgin()
    • Object.assign({}, arr)
  • will affect 'array inside array' if it modifies since it is shallow copying objects
  • Pitfall: ๊ณ„์† ์ˆœํ™˜ ์ฐธ์กฐ

Deep Copying Objects:

  • JSON.parse(JSON.stringify(object))
  • Pitafall: if you put user's method, it will cause an error.
  • ์„œ๋ฒ„ ํ†ต์‹ ์—์„œ๋Š” ๋”ฎ์นดํ”ผ๊ฐ€ ๋งž์Œ
  • ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋Š” ๊ฐ์ฒด๋‚˜ ๋ฐฐ์—ด์ด ์•„๋‹ˆ๋ผ ๊ทธ๋ƒฅ ๊ธ€์ž์ž„

 

 

 

reference:

https://scotch.io/bar-talk/copying-objects-in-javascript

https://medium.com/watcha/๊นŠ์€-๋ณต์‚ฌ์™€-์–•์€-๋ณต์‚ฌ์—-๋Œ€ํ•œ-์‹ฌ๋„์žˆ๋Š”-์ด์•ผ๊ธฐ-2f7d797e008a

'Today's Finding' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

Lexical Scope  (0) 2020.11.04
HOISTING  (0) 2020.11.04
Regular Expressions(์ •๊ทœํ‘œํ˜„์‹)  (0) 2020.10.28
How to calculate number easily in Javascript  (0) 2020.10.28
Shortcut in Mac  (0) 2020.10.27

From ๋ชจ๊ฐ์ฝ”...

 

Scope๋Š” ์ฒด์ธ์œผ๋กœ ์—ฐ๊ฒฐ์ด ๋˜์–ด ์žˆ์Œ

 

์ „์—ญ ์‹คํ–‰ ์ปจํ…์ŠคํŠธ๊ฐ€ ์žˆ์œผ๋ฉด, ๊ทธ๊ฒƒ์€ lexical environment๋ฅผ ๋ฐ”๋ผ๋ณด๊ณ  ์ฐธ์กฐํ•˜๊ณ  ์žˆ๊ณ , ๊ทธ๊ฒƒ์ด ์ฃฝ์ง€ ์•Š๋Š” ํ•œ lexical environment๋ฅผ ์ฐธ์กฐํ•  ์ˆ˜ ์žˆ๋‹ค.

 

Lexical enviornmentํ•œํ…Œ๋Š” ์ง„์งœ ์ž๊ธฐ ํ™˜๊ฒฝ์„ ์—ฐ๊ฒฐํ•œ ์†์„ฑ์ด ์žˆ๊ณ  outer lexical environment (์ƒ์œ„ ์Šค์ฝ”ํ”„)๋ฅผ ๊ธฐ์–ตํ•˜๊ณ  ์žˆ์Œ.

๊ฒฐ๊ตญ, ์ž๊ธฐ ์ƒ์œ„๊ฐ€ ๋ˆ„๊ตฐ์ง€ ๊ธฐ์–ตํ•˜๊ณ  ์ฐธ์กฐํ•ด์•ผํ•  ํ™˜๊ฒฝ์„ ์ฐธ์กฐํ•˜๊ณ  ์žˆ์Œ.

 

์‹คํ–‰ context scope์€ ์Šคํƒ ๊ตฌ์กฐ๋กœ ์Œ“์•„์ ธ ๋‚˜๊ฐ€๊ณ , ๋งจ ๋ฐ‘ ์‹คํ–‰ ์ปจํ…์ŠคํŠธ ์œ„์— ํ•จ์ˆ˜์˜ ์‹คํ–‰ ์ปจํ…์ŠคํŠธ๊ฐ€ ์Œ“์ด๊ฒŒ ๋œ๋‹ค.

 

์ „์—ญ ์‹คํ–‰ ์ปจํ…์ŠคํŠธ๊ฐ€ ๋ ‰์‹œ์ปฌ ํ™˜๊ฒฝ์„ ๊ฐ€์ง€๊ณ  ์žˆ์Œ ์ „์—ญ ์‹คํ–‰ ์ปจํ…์ŠคํŠธ ๋ฐ‘์— ์˜ฌ๋ผ์˜ค๋ฉด outer lexical reference environment๊ฐ€ ์‹ค์ œ ์‹๋ณ„์ž๊ฐ€ ์žˆ๋Š” ๊ณต๊ฐ„์„ ์ €์žฅํ•จ

 

์•ˆ์— ๋ณ€์ˆ˜๊ฐ€ ์—†์„ ๋•Œ ์ƒ์œ„์— ๋ณ€์ˆ˜๊ฐ€ ํ˜ธ์ถœ์ด ๋  ๋•Œ, ์ƒ์œ„ ์Šค์ฝ”ํ”„๋ฅผ ์ฐธ์กฐํ•˜๊ฒŒ ๋จ

 

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋Š” ํ•จ์ˆ˜๊ฐ€ ์ƒ์„ฑ์ด ๋  ๋•Œ ์ƒ์œ„ ์Šค์ฝ”ํ”„๊ฐ€ ๋ˆ„๊ตฌ์ธ ์ง€ ํ™•์ธํ•จ ๊ทธ๋ž˜์„œ lexical scope๋กœ ์ •ํ•ด๋†“์Œ

 

'Today's Finding' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

Shallow vs. Deep Copying Objects  (0) 2020.11.05
HOISTING  (0) 2020.11.04
Regular Expressions(์ •๊ทœํ‘œํ˜„์‹)  (0) 2020.10.28
How to calculate number easily in Javascript  (0) 2020.10.28
Shortcut in Mac  (0) 2020.10.27

From ๋ชจ๊ฐ์ฝ”...

 

ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋Š” interpreter language and compile language๋กœ ๋‚˜๋ˆ„์–ด์ง.

 

JavaScript๋Š” interpreter language์ด๊ธฐ์—, ์œ„์—์„œ๋ถ€ํ„ฐ ํ•œ ์ค„์”ฉ ์ฝ๊ฒŒ ๋จ(๋Ÿฐํƒ€์ž„). ๊ทธ๋ฆฌ๊ณ , ๋Ÿฐํƒ€์ž„ ์ด์ „์— ๋ฌธ์„œ๋ฅผ ํ•œ ๋ฒˆ ์ฝ์–ด์„œ ์„ ์–ธ๋ฌธ์ด ์žˆ์œผ๋ฉด ๊ณต๊ฐ„์„ ๋จผ์ € ๋งŒ๋“ค์–ด ์คŒ.

 

์„ ์–ธ๋ฌธ์„ ์•ž์œผ๋กœ ๋Œ์–ด์„œ ํ˜ธ์ด์ŠคํŒ… ํ•˜๋Š” ๊ฒƒ์€ lexical environment์ž„

 

์œˆ๋„์šฐ ๊ฐ์ฒด์— ์ „์—ญ๋ณ€์ˆ˜๊ฐ€ ์ €์žฅ์ด ๋˜๊ณ , ๋จผ์ € ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„์ด ๋งŒ๋“ค์–ด ์ง. ๋ฉ”๋ชจ๋ฆฌ ์ฃผ์†Œ๋ฅผ ๋งŒ๋“ค๊ณ , ํ• ๋‹น์ด ๋‹นํ–ˆ์„ ๋•Œ ์ €์žฅ์ด ๋จ.

 

ํ• ๋‹น๋ฌธ์„ ๋งŒ๋‚˜์•ผ๋งŒ ์šฐ๋ณ€์ด ์ƒ์„ฑ๋˜๋ฉฐ ์šฐ๋ณ€์˜ ๊ฐ’์ด ํ‰๊ฐ€๊ฐ€ ๋˜๊ณ , ์˜ค๋ฅธ์ชฝ์—์„œ ํ‰๊ฐ€ํ•ด์„œ ์™ผ์ชฝ์œผ๋กœ ๋„ฃ์Œ.

 

์„ ์–ธ๋ฌธ์€ ๋Ÿฐํƒ€์ž„์ด์ „์— ์„ ์–ธ๋œ ๋ชจ๋“  ๊ฒƒ์„ ์•ž์ชฝ์—์„œ ์„ ์–ธ๋˜๋Š” ํ˜ธ์ด์ŠคํŒ…์ด ์ผ์–ด๋‚จ.

 

ํ‘œํ˜„์‹์€ ํ• ๋‹น๋ฌธ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋Ÿฐํƒ€์ž„์— ์ƒ์„ฑ์ด ๋˜๋ฉฐ ํ˜ธ์ด์ŠคํŒ…์ด ์•ˆ์ผ์–ด๋‚˜๋‹ˆ๊น ์“ฐ๊ธฐ ๋” ๋‚˜์Œ

 

๋ณ€์ˆ˜์— ๊ฐ’์ด ๋“ค์–ด๊ฐ€๋Š” ๊ฑฐ์—์„œ ํ•จ์ˆ˜๊ฐ€ ๋ณ€์ˆ˜์— ๋“ค์–ด๊ฐ€๋Š” ๊ฒƒ๋„ ํ• ๋‹น์ด๊ธฐ์— ๋Ÿฐํƒ€์ž„์— ์ƒ๊น€. ์˜ˆ๋ฅผ ๋“ค์–ด, const a= function()

 

์ˆœ์„œ์— ๋งž๊ฒŒ ์ ์–ด๋ผ! ๋ฐ‘์— ํ• ๋‹นํ•œ ๊ฒƒ์„ ์œ„์—์„œ ์“ฐ์ง€ ๋งˆ๋ผ. ํ˜ธ์ด์ŠคํŒ…์„ ์•…์šฉํ•˜์ง€ ๋ง์ž.

 

more details:

joshua1988.github.io/web-development/javascript/function-expressions-vs-declarations/

'Today's Finding' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

Shallow vs. Deep Copying Objects  (0) 2020.11.05
Lexical Scope  (0) 2020.11.04
Regular Expressions(์ •๊ทœํ‘œํ˜„์‹)  (0) 2020.10.28
How to calculate number easily in Javascript  (0) 2020.10.28
Shortcut in Mac  (0) 2020.10.27
  • Closure
    • closure function can access
      • innver variable
      • outer variable
      • global variable
        1
        2
        3
        4
        5
        6
        7
        8
        9
        function 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
        1
        2
        3
        4
        5
        6
        7
        8
        function multiply(x) {
            return function(y) {
                return x * y;
            }
        }
        multiply(3)(4); // 12
        let multiply10 = multiply(10);
        multiply(7); // 70
        cs
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        12
        13
        function 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 
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        function calculate() {
            let insideCalculate = 0;
         
            let obj = {
                increment: function() {
                    insideCalculate ++;
                },
                decrement: function() {
                },
                getValue: function() {
                    return insideCalculate;
                }
            };
            return obj;
        }
        let one = calculate();
        one.increment();
        one.increment()l
        one.getValue(); // 2
        insideCalculate; // reference error
        let two = calculate();
        two.increment();
        two.increment();
        two.increment();
        two.increment();
        two.increment();
        two.decrement();
        two.getValue(); // 5
        cs

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
    • 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
  1. Primitive Type(์›์‹œ ํƒ€์ž…)
    • string
    • number
    • biginit
    • boolean
    • undefined
    • symboll
    • null
    • ์žฌํ• ๋‹น ํ•˜๋”๋ผ๋„, ์ฒ˜์Œ ํ• ๋‹นํ–ˆ๋˜ ๊ฐ’์ด ๋ฐ”๋€Œ์ง€ ์•Š์Œ
  2. Reference Type(์ฐธ์กฐ ํƒ€์ž…)
    • function
    • array
    • object
    • ์žฌํ• ๋‹นํ•˜๋ฉด, ๋ชจ๋“  ๊ฒƒ์ด ์ž๋™์ ์œผ๋กœ ๋‹ค ๋ฐ”๊ฟ”๋ฒ„๋ฆผ
    • save inside 'heap'
      1
      2
      console.log([1,2,3=== [1,2,3]; // false 
      console.log({ foo: 'ba' } === { foo: 'ba' }); // false
      cs
  3. SCOPE(๋ฒ”์œ„)
    • determines the accessibility of variables
    • JS receive own scope once function was created, which is lexical scope
      • check who is its outer scope
    • can put function inside function
      1.  Local Scope vs. Global Scope
        • Local Scope 
          • 'Local Variable'(์ง€์—ญ๋ณ€์ˆ˜) has higher priority than global variable and cannot use it outside function
            1
            2
            3
            4
            5
            6
            7
            8
            let greeting = 'Hi';
            function greet() {
                let greeting = 'Hello';
                console.log(greeting); // 'Hello'
            }
            console.log(greeting); // 'Hi'
            greet();
            console.log(greeting); // 'Hi'
            cs
            1
            2
            3
            4
            function greetSomeone() {
            let firstName = 'Paige';
            return greeting + ' ' + firstName;
            }
            cs
        • Global Scope
          • 'Global Variable'(์ „์—ญ๋ณ€์ˆ˜) can access everywhere
            1
            2
            3
            4
            5
            6
            7
            8
            let greeting = 'Hi';
            function greetSomeone() {
            let firstName = 'Paige';
            return greeting + ' ' + firstName;
            }
             
            greetSomeone(); // => Hi Paige'
            firstName; // => ReferenceError
            cs
      2. Function Scope vs. Block Scope
        • Block
          • starts and end with curly bracket { }
          • var vs. let
            • var: gets its own scope (old way)
              • connects with window object
            • let: only works inside block scope
                let const var
              scope block scope block scope function scope
              reassignment(์žฌํ• ๋‹น) โญ•๏ธ โŒ โŒ
              redeclaration(์žฌ์„ ์–ธ) โŒ โŒ โŒ
      3. Global Variable(์ „์—ญ๋ณ€์ˆ˜) and Window object(์œˆ๋„์šฐ๊ฐ์ฒด)
        • will connect to function that is assigned at global scope and var varible
        • do not declare too much in global scope!
          1
          2
          3
          4
          5
          6
          7
          8
          var myName = "Paige";
          console.log(window.myName); // Paige
           
          function foo() {
          console.log('bar');
          }
           
          console.log(foo === window.foo); // true
          cs
      4. No Declaration(์„ ์–ธ์—†์ด ์ดˆ๊ธฐํ™”๋œ ์ „์—ญ๋ณ€์ˆ˜)
        • do not use variable without assignment
        • if it does, it becomes global variable(์ „์—ญ๋ณ€์ˆ˜)
        • In order to avoid error, use 'use strict'
          1
          2
          3
          4
          5
          6
          7
          function showAge() {
          age = 24;
          console.log(age);
          }
          showAge(); // 24
          console.log(age); // 24
          age === window.age
          cs

  • Spread Syntax(...variable)
    • if spread syntax goes inside parameter, it become 'rest parameter(rest syntax)'
      1
      2
      3
      4
      function pintMaxNums(...args) { 
          console.log(args); //[10, 30, 40]
      }
      pintMaxNums(103040); 
      cs

       

'TIL' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

TIL 2020.11.05  (0) 2020.11.05
TIL 2020.11.04  (0) 2020.11.04
TIL 2020.11.02  (0) 2020.11.02
TIL 2020.11.01  (0) 2020.11.01
TIL 2020.10.30  (0) 2020.10.30

WHAT I LEARNED

 

For this array and method pair, my pair has a better understanding of how JavaScript works and how each of us should act as a driver and a navigator. The funny thing is I understood each task as the opposite and did not know what to do lol. But at least I got to understand and have been able to act as a driver and a navigator. And, I think I should study one day in advance to fully understand the topic while doing coplit. Even though I started to study arrays and objects since yesterday, I was frustrated that I could not do the same as what my pair did. Because of my pair, we were able to finish earlier than the schedule. Time to review more and more ๐Ÿฅต


  1. Array (๋ฐฐ์—ด) [ ] square bracket!
        • Element: each value of index and seperate with comma inside array
        • can change element as well
        • Index: order inside array and starts with '0'
          1
          2
          3
          4
          5
          let list = [571113];
          list[0= 5;
          list[2= 11;
          list [3= 99;
          list; // [5, 7, 11, 99]
          c

           

        • Property:
          • length: list.length
            1
            2
            let list = [571113];
            list.length = 4;
            cs
        • Method:
          • list.push : add element to back **MUTABLE
          • list.pop: remove element from back **MUTABLE
          • list.shift: remove element from front **MUTALBE
          • list.unshift : add element to front **MUTABLE
            1
            2
            3
            4
            5
            let list = [571113];
            list.push(99); // [5, 7, 11, 13, 99]
            list.pop(); // [5, 7, 11, 13]
            list.shift(); // [7, 11, 13]
            list.unshift(5); // [5, 7, 11, 13]
            cs
          • Array.isArray:  check whether it is array or not
            1
            2
            3
            let list = [571113];
            Array.isArray(list); // true;
            Array.isArray([1 ,23]); // true;
            cs
            • if you use typeof, object and array show both as object
              1
              2
              3
              4
              let list = [571113];
              typeof list // "object"
              let obj = {a :1};
              typeof obj // "object"
              cs
            • Case sensitive
            • if it does not exist, returns as -1
          • indexOf: check whether it is inside array and returns as index( first index at which a given element can be found in the array, or -1 if it is not present.)
            1
            2
            3
            4
            5
            6
            7
            8
            let list = ['Paige''Kim'24];
            list.indexOf('Paige'); // 0
            list.indexOf('paige'); // -1
            list.indexOf('Paige'!== -1// true
            function hasElemnet(arr, element) {
              return list.indexOf(element) !== -1;
            }
            hasElement(list, 'Paige'// true
            cs
          • includes: can check whether it includes or not
            1
            2
            3
            let list = ['Paige''Kim'24];
            list.includes('Paige'); // true
            list.indexOf('Joo Hee'); // -1
            cs
            • does not apply in internet explorer
          • arr.length === 0 or !arr.length
            • to receive empty array
          • splice(starting index, how many from starting index)  ** MUTABLE
            • delete: delete index 0 and 1 represents delete
            • insert: insert at index 1 location and 0 represents insert
            • replace: delete index 1 and replace 
              1
              2
              3
              4
              var colors = ["red""green""blue"];
              colors.splice(01); // ["green", "blue"]
              colors.splice(1, 0"yellow""orange"); 
              // ["green", "yellow", "orange", "blue"]
              colors.splice(1, 1"red""purple"); 
              // ["green", "red", "purple", "orange", "blue"]
              cs
          • slice(startIndex, lastIndex) : *IMMUTABLE
            • last index will not include
            • ์–•์€ ๋ณต์‚ฌ!
              • ๋ฐฐ์—ด ์•ˆ์˜ ๋ฐฐ์—ด์ด ์žˆ๋‹ค๋ฉด, ์ฃผ์†Œ๋ฅผ ์ฐธ์กฐํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ๋‚ด์šฉ์ด ๋ณ€ํ•จ
              • ์›์‹œํƒ€์ž…์€ ์ˆœ์ˆ˜ ๋ณต์‚ฌ, ์ฃผ์†Œํƒ€์ž„์€ ์ฃผ์†Œ ๋ณต์‚ฌ
              • github.com/codestates/pre-help-desk/issues/2366

            • var arr = [123456];
              var sliced = arr.slice(14); // [2, 3, 4]
              arr.slice(11); // []

             

          • concat:
            • merging arrays
              1
              2
              3
              4
              var array1 = ['a''b''c'];
              var array2 = ['d''e''f'];
              var array3 = array1.concat(array2);
              console.log(array3); // [a, b, c, d, e, f]
              cs
          • Convert to Array from String ๐Ÿคฏ
            • string.split(): split string with comma and conver to array
              1
              2
              let str = "Hi I am Paige"
              str.split(" "// ["Hi", "I", "am", "Paige"]
              cs
              1
              2
              3
              let code = 'codestates';
              code.split(' '); // ["codestates"]
              code.split(''); // ["c", "o", "d", "e", "s", "t", "a", "t", "e", "s"]
              cs
          • Convert to String from Array ๐Ÿคฏ
            • for ... of statement ๋ฐ˜๋ณต๊ฐ€๋Šฅ ๊ฐ์ฒด!!!
              1
              2
              3
              4
              5
              6
              7
              const array1 = ['a''b''c'];
              for (const element of array1) {
                console.log(element); 
              }
              //"a"
              //"b"
              //"c"
              cs
            • join():
              1
              2
              3
              4
              let list = [571113];
              list.join() // "5, 7, 11, 13"
              list.join(""// "571113"
              list.join("-"// "5-7-11-13"


               

  2. OBJECT (๊ฐ์ฒด)
    • Dot Notation: need to use when key is changeable
    • Bracket Notation: need to put String inside bracket
      • better to use over dot notation  parameter could be changed as well
      • always put inside square bracket as 'String', if not probably receive reference error
      • if you put as user[firstname], firstname applies as varialbe
      • 1
        2
        3
        4
        5
        6
        7
        8
        9
        let user = {
            firstName: 'Paige',
            lastName: 'Kim',
            email: 'paigekim29@gmail.com';
            city: 'Seoul'
        };
        user.firstName; // 'Paige'
        user['firstName']; // 'Paige'
        user.firstName === user['firstName'];
        cs
    • key-value pair => Property
      • firstName = key  
      • 'Paige' = value
    • add value
      1
      2
      3
      user['gender'= 'female';
      user.hobby = ['#golf'  , '#pilates'];
      user.skinny = false;
      cs
    • delete value & key
      • if you delete value, it deletes key together!!
        1
        delete user.hobby;
        cs
    • in: check values and returns as boolean
      1
      2
      'hobby' in user; // false
      'firstName' in user; // true
      cs
    • HOW TO ITERATE (๊ฐ์ฒด ์ˆœํšŒํ•˜๊ธฐ) ๐Ÿคฏ
      • for ... in statement ๊ฐ์ฒด์—์„œ key๊ฐ’ ๋ฝ‘๊ธฐ!!!
        1
        2
        3
        4
        5
        6
        7
        8
        let user = {
            firstName: 'Paige',
            lastName: 'Kim'
        };
         
        for (var item in user) {
            console.log(item, user[item]);
        // firstName Paige, lastName Kim
        cs
      • Object.keys()
        • Make an array with key only
      • Object.values()
        • Make an array with values only
      • Object.entries()
        • Make an array inside array with key and value
          1
          2
          3
          4
          5
          6
          7
          8
          9
          let list = {
            name'Paige',
            age: 24,
            hobby: 'pilates'
          };
          Object.values(list); // ["Paige", 24, "pilates"]
          Object.keys(list); // ["name", "age", "hobby"]
          Object.entries(list) // [["name", "Paige"], ["age", 24], ["hobby", "pilates"]]
           
          cs

 

CONSOLE.TABLE:

 

 

 

 

 

 

 

 

 

 

'TIL' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

TIL 2020.11.04  (0) 2020.11.04
TIL 2020.11.03  (0) 2020.11.03
TIL 2020.11.01  (0) 2020.11.01
TIL 2020.10.30  (0) 2020.10.30
TIL 2020.10.29  (0) 2020.10.29

WHAT I LEARNED

 

For the first weekend, I had some rest and was able to sleep more. I lacked sleep because of the stress I got from the crash course. I thought I would be able to follow their timeline (Well, at least for the first week) but apparently I was already struggling from the beginning. Though, there is no time to be frustrated! I went over all the topics I learned for this week and finished reading one third of the book: 'JavaScript for Web Developers'. I read this book before but I did not understand fully. Though, after hearing code states lectures, I was able to understand it more. I made a goal to finish this book while taking the bootcamp. I think I would be able to do it since reading this book actually reminds me of what I have learned; and, it provides detailed information that I never thought about.

 

 

Websites for CSS:

https://flukeout.github.io/

https://lubna.dev/colouring-with-code/

https://codepen.io/Lubna/pen/zYYzOxN

https://codepen.io/Lubna/pen/dyoqzwP

https://flexboxfroggy.com/#ko

 

 

'TIL' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

TIL 2020.11.03  (0) 2020.11.03
TIL 2020.11.02  (0) 2020.11.02
TIL 2020.10.30  (0) 2020.10.30
TIL 2020.10.29  (0) 2020.10.29
TIL 2020.10.28  (0) 2020.10.28

WHAT I LEARNED

 

This was the first project that I needed to work on to be able to make a base calculator using html, css, and JavaScript. I studied iteration continuously for the last two days so my head is just full of that. So, when I first started this project, I only thought about using iteration. But later, I realized that iteration wasn't needed and instead I should use an if statement, which was correct. It took awhile to apply my knowledge into a project but I made about 90%(?) before the "office hour". Then, I realized that I did not fully understand the concept of JavaScript. So,  I decided that I will read a book about JavaScript this weekend while reviewing what I learned. For this JavaScript project, I met a new partner. I worked as the "navigator" for most of the time. My partner felt embarrassed to keep asking questions but I felt like asking questions and talking about the project more really helps in understanding the concept and reviewing about it more. Moreover, I figured out the problem I was facing on my coding. Finally, first week is over๐Ÿฅณ 19 weeks left and I am excited to learn more new concepts.


JavaScript Calculator

  1. Toggle : can add and remove once clicked
  2. parseFloat() : returns real number and can string into number
  3. parseInt() : parses a string argument and returns an integer of the specified radix

 

 

 

'TIL' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

TIL 2020.11.02  (0) 2020.11.02
TIL 2020.11.01  (0) 2020.11.01
TIL 2020.10.29  (0) 2020.10.29
TIL 2020.10.28  (0) 2020.10.28
TIL 2020.10.27  (0) 2020.10.27

WHAT I LEARNED

 

I spent most of the time reviewing iteration instead of focusing on html and css as scheduled. I could say that I got a little bit more familiar with iteration but I still need to practice continuosly in order to be fully understand it. During the office hour, I asked whether giving the height:100vh and flex:1 are the same because it gives how long each div should be. Apparently, those are totally different concepts that I should not mix together. Also, I thought that I was aware of most of the tags but the fact is I was wrong. lol Time to study more๐Ÿค“


HTML & CSS

  1. Most used tags in html but I didnt know about
    • <textarea> </textarea>: Multi-line Text Input
    • ul, li : ul can be under li again in order to be nested
    • <input type="radio" name="choice" value="a"> : assign name with other radio input to be connected
  2. CSS
 

flex

The flex CSS shorthand property sets how a flex item will grow or shrink to fit the space available in its flex container.

developer.mozilla.org

  • Difference among Block, Inline-block, and Inline 
  BLOCK INLINE-BLOCK INLINE
Width 100% Up to letters Up to letters
Width, Height โญ•๏ธ โญ•๏ธ โŒ
Line Break โญ•๏ธ โŒ โŒ
Margin โญ•๏ธ โญ•๏ธ Left & Right
Padding โญ•๏ธ โญ•๏ธ โญ•๏ธ

 


ITERATION

  1. Break & Continue
 

The difference between break and continue in JavaScript - Kieran Barker

In JavaScript, the break and continue statements both let you control what's happening inside a loop. But they do very different things. Let's jump right in and look at the differences! For the following examples, let's assume an array of flavours for cris

kbarker.dev

'TIL' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

TIL 2020.11.01  (0) 2020.11.01
TIL 2020.10.30  (0) 2020.10.30
TIL 2020.10.28  (0) 2020.10.28
TIL 2020.10.27  (0) 2020.10.27
TIL 2020.10.26  (0) 2020.10.26

+ Recent posts