๐Ÿ“
til
  • TIL(Today I Learned)
  • javascript
    • value-number-string-boolean-null-undefined
    • primitive-reference
    • Hoisting
    • Prototypes in Javascript
    • this
    • prototype
    • ์ฝœ๋ฐฑํ•จ์ˆ˜ (Callback function)
    • ํ•จ์ˆ˜์˜ ํ˜ธ์ถœ
    • ์ž๋ฃŒ๊ตฌ์กฐ new keyword
    • closure
    • Promise
    • event-loop
    • array-object
    • ๊ฐ์ฒด
    • Arguments
    • higher order function
    • operators-function-control-flow
    • ๊ฐ์ฒด ์ƒ์„ฑ ํŒจํ„ด 3๊ฐ€์ง€
    • Javascript scopes
    • Functional Programming
    • Design Patterns
    • ๋ฐ์ดํ„ฐ ํƒ€์ž…
    • Object ๊ฐ์ฒด
    • ํ‘œ์ค€ ๋‚ด์žฅ ๊ฐ์ฒด์˜ ํ™•์žฅ
    • ์ฐธ์กฐ
    • ํ•จ์ˆ˜
    • ์ƒ์†(Inheritance)
    • this - 'this'๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ํ•ด๋‹น ํ•จ์ˆ˜๋ฅผ '์–ด๋–ป๊ฒŒ' ์‹คํ–‰ํ•˜๋А๋ƒ์— ๋”ฐ๋ฅธ 4๊ฐ€์ง€ this ์ •์˜
    • ์ „์—ญ๊ฐ์ฒด(Global object)
    • ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ
    • The 'new' keyword - Object Creation in JavaScript
  • javascript-api
    • Number
      • Number.MAX_VALUE
      • Number.isInteger
      • Number.NEGATIVE_INFINITY
      • Number.isNaN()
      • Number.POSITIVE_INFINITY
      • Number.parseFloat
      • Number.EPSILON
      • number.toExponential
      • Number.MAX_SAFE_INTEGER
      • Number1 - ์ž์—ฐ์ˆ˜, ์ •์ˆ˜, 10์ง„์ˆ˜, 2์ง„์ˆ˜, ๋ถ€๋™์†Œ์ˆ˜์ , ์‹ค์ˆ˜
      • Number.isSafeInteger()
      • Number.MIN_VALUE
      • Number.parseInt
      • Number.NaN
      • Number.isFinite()
      • Number.MIN_SAFE_INTEGER
      • toFixed
    • string.split
    • String.fromCodePoint
    • string.trimEnd
    • string.padStart
    • string.@@iterator
    • String.fromCharCode
    • string.toUpperCase
    • string.codePointAt
    • string.toLowerCase()
    • string.toString
    • string.includes
    • string.replace()
    • string.charAt
    • String.lastIndexOf
    • string.slice
    • string.search
    • string.padEnd
    • string.substring
    • string.length
    • string.trim
    • string.localeCompare
    • String.indexOf
    • string.endsWith
    • string.valueOf
    • String.raw
    • string.matchAll()
    • string.repeat
    • string.match
    • String.prototype
    • string.startsWith
    • string.charCodeAt
    • string.trimStart
    • string.concat
    • string.toLocaleUpperCase()
    • string.toLocaleLowerCase
    • String
  • learn-node
    • debugger
    • Tip
  • schema-design
    • Database Schema Design
    • Database Schema Design
  • react
    • LifeCycle
    • redux
    • Context API
    • ํ•จ์ˆ˜ํ˜• ์ปดํฌ๋„ŒํŠธ์™€ ํด๋ž˜์Šค, ์–ด๋–ค ์ฐจ์ด๊ฐ€ ์กด์žฌํ• ๊นŒ?
    • Hooks๊ณผ useEffect ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ
    • Route
    • async wait ์‚ฌ์šฉํ•˜๊ธฐ
    • Hooks API Reference
    • context
    • npm uninstall ํ•˜๋Š”๋ฒ•
    • test ๋งŒ๋“ค๊ธฐ
  • tip
    • ํด๋ฆฐ์ฝ”๋“œ
    • BxSlider๋กœ ํ…์ŠคํŠธ ํ๋ฅด๋Š” ํšจ๊ณผ ๋งŒ๋“ค๊ธฐ
  • javascript30
    • Event Capture, Propagation, Bubbling and Once
    • Object and Arrays - Reference VS Copy
  • typescript
    • ์šฐ์•„ํ•œ ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ 2๋ถ€
    • The Basic Cheatsheet
    • TypeScript
    • Type Guards and Differnetiating Types
    • ์šฐ์•„ํ•œ ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ
    • Generics
  • git-from-the-hell
    • git
    • init-status-add-commit-log-stage-repository
    • log-diff
    • ๋จธ์ง€ ํ›„ branch ์‚ญ์ œํ•˜๊ธฐ
    • ์ง€์˜ฅ์—์„œ ์˜จ Git
    • reset-revert
    • develop branch ๋ฅผ pull ํ•˜๊ณ  ์‹ถ์„๋•Œ
  • conference-and-seminar
    • ๋ชจ๋˜ ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœํ™˜๊ฒฝ์˜ ์ดํ•ด
  • fire-base
    • Firebase .gitignore
  • vanillacoding
    • Data Structures
    • Sorting Algorithms - part 1
    • Promise
    • class
    • 04.quiz
    • 07.event-loop
    • Design Patterns
    • OOP (Object Oriented Programming)
  • etc
    • ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ฝ”๋“œ๋ฆฌ๋ทฐ
    • ์Šค์Šค๋กœ ๊ณต๋ถ€ํ•˜๋Š” ๋ฒ•
    • ๋ฐ”๋‹๋ผ์ฝ”๋”ฉ ์ˆ˜๊ฐ• ํ›„๊ธฐ
    • async ๊ณผ์ œ ํ›„๊ธฐ - ๋น„๋™๊ธฐ, ๋™๊ธฐ, ํด๋กœ์ €, ๋ฐฐ์—ด๊ณผ ๊ฐ์ฒด
    • ์œ ์šฉํ•œ ์‚ฌ์ดํŠธ
  • algorithm
    • The Supermarket Queue
    • Find the odd int
    • The Office III - Broken Photocopier
    • Directions Reduction
    • The Office II - Boredom Score
    • Divisible Sum Pairs
    • Codewars ์ด์šฉ์ž ์†”๋ฃจ์…˜ ๋ชจ์Œ
    • Shortest Word
    • find key
    • Two Sum
    • Simple Pig Latin
  • Book
    • the essence of object-orientation
      • ํƒ€์ž…๊ณผ ์ถ”์ƒํ™”
      • ๊ฐ์ฒด ์ง€๋„
      • ์ด์ƒํ•œ ๋‚˜๋ผ์˜ ๊ฐ์ฒด
      • ์ถ”์ƒํ™” ๊ธฐ๋ฒ•
      • 05. ์ฑ…์ž„๊ณผ ๋ฉ”์‹œ์ง€
      • 07.ํ•จ๊ป˜ ๋ชจ์œผ๊ธฐ
      • 04. ์—ญํ• , ์ฑ…์ž„, ํ˜‘๋ ฅ
      • ํ˜‘๋ ฅํ•˜๋Š” ๊ฐ์ฒด๋“ค์˜ ๊ณต๋™์ฒด
  • ecma-script2015
    • Object Literal Upgrades
    • default-parameter-template-literals-arrow-functions
    • spread-operator-rest-param
    • let-const-rest-parameter-spread-operator-destructuring
  • http
    • ์›น ๋ธŒ๋ผ์šฐ์ €์— URL์„ ์ž…๋ ฅํ–ˆ์„ ๋•Œ ์–ด๋–ป๊ฒŒ ์›น ํŽ˜์ด์ง€๊ฐ€ ๋ณด์—ฌ์งˆ๊นŒ?
  • jest
    • toThrow(error?)
  • data-structures
    • Data Structures
  • express
    • express generator
    • CORS
  • css-flexible-box-layout
    • flex ํ•ด๋ฒ„๋ ธ์ง€ ๋ญ์•ผ
  • git
    • Git
  • mongodb
    • MongoDB
  • markdown
    • use-markdown
  • cmder
    • cmd ๋ช…๋ น์–ด ๋ชจ์Œ
  • debug
    • trackClicksEx function error
  • npm
    • NPM TOKEN ์„ค์ •ํ•˜๊ธฐ
  • storybook
    • Storybook
  • sort
    • Sorting Algorithms - part 1
  • javascript-koans
    • Javascript Koans ์˜ค๋‹ต๋…ธํŠธ
  • rxjs
    • Rx.js
  • dom-elements
    • HTML Element
  • redux-toolkit
    • Redux Toolkit
  • github-actions
    • GitHub Actions
  • redux-middleware
    • redux middleware
  • rest
    • rest
  • css-rendering
    • ์ฝ”๋“œ ์Šคํ”ผ์ธ  - CSS Rendering 1ํšŒ์ฐจ 2/2
    • ์ฝ”๋“œ ์Šคํ”ผ์ธ  - CSS Rendering 1ํšŒ์ฐจ 1/2
  • you-dont-know-js
    • ํƒ€์ž…
  • server
    • # shutdown local server
  • semantic-versioning
    • Semantic Versioning 2.0.0
Powered by GitBook
On this page
  • Operator
  • Function
  • arguments
  • return
  • Control Flow

Was this helpful?

  1. javascript

operators-function-control-flow

Previoushigher order functionNext๊ฐ์ฒด ์ƒ์„ฑ ํŒจํ„ด 3๊ฐ€์ง€

Last updated 5 years ago

Was this helpful?

Operator

false || true && false

์—ฐ์‚ฐ์ž ์šฐ์„ ์ˆœ์œ„๊ฐ€ ์žˆ๋‹ค. ์‚ฌ๋žŒ์ด ์ฝ๋Š”๊ฒŒ ์ฝ”๋“œ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋จผ์ € ์—ฐ์‚ฐ๋˜๊ธธ ๋ฐ”๋ผ๋Š” ๊ณณ์—” ๊ด„ํ˜ธ๋ฅผ ๋จผ์ € ํ•˜๋Š”๊ฒŒ ์ข‹๋‹ค.

[MDN ๋…ผ๋ฆฌ์—ฐ์‚ฐ์ž ์˜ˆ์‹œ๋ณด๊ธฐ]([))

Function

arguments

function add(x, y) {
    console.log(arguments[0]);
    console.log(arguments.length);
    return x + y;
}

์œ ์‚ฌ๋ฐฐ์—ด์ด๋ผ๊ณ  ํ•  ์ˆ˜ ์žˆ๋‹ค.

function add(x, y){
    return function bar () {};
}

console.log(add() || 3) //function bar() {};

console.log(add()() || 3); //3

์ฒซ๋ฒˆ์งธ console ์ฐ์€๊ฑด return ๋‹ค์Œ์˜ function bar () {}; ๋ฅผ ๋‚˜ํƒ€๋‚ธ๋‹ค. ๋‘๋ฒˆ์งธ console ์ฐ์€๊ฑด bar๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š”๋ฐ returnํ•˜๋Š”๊ฒŒ ์—†๊ธฐ๋•Œ๋ฌธ์— undefined๋‹ค

return

function a(b){
    return 
}
console.log(a); //undefined

return์€ return ๋ฌธ๊ตฌ๋ฅผ ์‹คํ–‰์‹œํ‚ค๊ณ  function์„ ์ข…๋ฃŒ ์‹œํ‚จ๋‹ค.

ํด๋กœ์ € ์Šค์ฝ”ํ”„๋ฅผ ์ฐพ์•„์„œ ๊ณต๋ถ€ํ•ด๋ณด๊ธฐ

Control Flow

if(Truthy & Falsy) //true false๊ฐ€ ์•„๋‹ˆ๋ผ Truthy & Falsy๋ƒ
if(์ด ์•ˆ์€ ํ™•์‹คํ•˜๊ฒŒ ์ฝ์„ ์ˆ˜ ์žˆ๊ฒŒ ์งœ๋Š”๊ฒŒ ์ข‹๋‹ค. ๋„˜ ๊ธธ๋ฉด ํ•จ์ˆ˜ ์ถ”์ฒœ)

function areValidNumbers(){};

if(areValidNumbers)

์ด๋ ‡๊ฒŒ ์งค๋•Œ์˜ ์žฅ์ ์€ ๊ตณ์ด ๊ธด if๋ฌธ์„ ์•ˆ๋ณด๊ณ  function ์ด๋ฆ„๋งŒ ๋ณด๊ณ  ๋‚ด์šฉ์„ ์œ ์ถ”ํ•˜๊ณ  ๋„˜์–ด๊ฐ€๋„ ๋ ๋•Œ ์œ ์šฉํ•˜๋‹ค.

var i = 0;
function init () {
    console.log('me');
}

function isValid () {
    console.log('you');
    return i < 3;
}

funcrion update () {
    console.log('we');
    i++
}

for (init(); isValid(); update()){
    console.log(i)
}

์ด๋ ‡๊ฒŒ ํ• ๋•Œ console.log์—” ์–ด๋–ป๊ฒŒ ์ฐํž๊นŒ? 1. me 2. you 3. 1 4. we 5. you 6. 2 7. we 8. you ์˜ˆ์ƒ

for (์ œ์ผ ์ตœ์ดˆ์˜ 1ํšŒ์„ฑ; ์กฐ๊ฑด; ์—…๋ฐ์ดํŠธ)
var i = 0;
function init () {
    console.log('me');
}

function isValid () {
    console.log('you');
}

function foo () {

    for (init(); isValid(); console.log('update')){
        return;
    }
}

foo();

์˜ˆ์ƒ 1. me 2. you

var i = 0;
function init () {
    console.log('me');
}

function isValid () {
    console.log('you');
    return i < 3;
}

function foo () {

    for (init(); isValid(); console.log('update')){
        return; //์ด๊ฒƒ๋˜ํ•œ undefined๋ฅผ ๋ฆฌํ„ดํ•œ๋‹ค. 
    }
}

์˜ˆ์ƒ 1. me 2. you 3. undefined

return์€ return๊ตฌ๋ฌธ์„ ์‹คํ–‰ํ•˜๊ณ ! ํ•จ์ˆ˜์ข…๋ฃŒ์“ฐ!

break, continue๋ฅผ ์ฐพ์•„๋ณธ๋‹ค - loof์™€ ๊ด€๋ จ๋œ๊ฑฐ, function์ด๋ž‘์€ ์ƒ๊ด€์—†๋‹ค

https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/%EB%85%BC%EB%A6%AC_%EC%97%B0%EC%82%B0%EC%9E%90(Logical_Operators)](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/๋…ผ๋ฆฌ_์—ฐ์‚ฐ์ž(Logical_Operators