본문 바로가기

전체글

(45)
[Javascript] pass by reference 힘차게 등장~! Objects are passed by reference. This means when we pass a variable assigned to an object into a function as an argument, the computer interprets the parameter name as pointing to the space in memory holding that object. As a result, functions which change object properties actually mutate the object permanently (even when the object is assigned to a const variable). 이렇다는데(credit: codecademy) 예에..
[Javascript] 아니 그래서 왜 filter method 안에 return이 있어야 하는 건데? 지금 들어와서 잘 준비 다 마쳤는데... 조금이라도 공부하는 게 좋을 것 같아서 블로그 들어왔당 깔끔하게 공부하고 내일 일찍 일어나서 간장새우장 먹어야지ㅋㅅㅋ let story = 'Last weekend, I took literally the most beautifull bike ride of my life. The route is called "The 9W to Nyack" and it stretches all the way from Riverside Park in Manhattan to South Nyack, New Jersey. It\'s really an adventure from beginning to end! It is a 48 mile loop and it literally took me ..
[Javascript] 힘내자 진짜... 힘내자... 개힘들지만 그래도 공부는 계속해야 해... 오늘은 grammar checker를 마쳐야 한다구... 더 이상 질질 끌면 절대 안 돼 나중에 자바스크립트 딥다이브 사서 봐야지... 책을 샀는데 이해를 못 하면 안 되잖아... 우씨ㅠ 이거 듣고 노마드 강의 바로 들을까 점점 처지고 재미도 없는 기분인디... 클론코딩이 훨 재밌을 것 같다ㅇㅅㅇ let story = 'Last weekend, I took literally the most beautifull bike ride of my life. The route is called "The 9W to Nyack" and it stretches all the way from Riverside Park in Manhattan to South Nyack..
[Javascript] 문제 틀렸어!!!!!!!!!!!!!!!! In the following Javascript code snippet, the callback function cb is a function that sums the value of two numbers. Fill in the blank so that when the function is passed into the higher order function hof, it is then invoked so that the value returned is 8. let cb = (n1, n2) => {return n1 + n2}; let hof = (func) => { let value = cb(3, 5); // 여기 return `this function returned ${value}`; } hof(cb..
[Javascript] 푹 쉬고 다시 시작 오랜만에 쉬니까 너무 너무 좋아서 그냥 푹 쉬어버렸다ㅋㅋㅋㅋㅋ 그래도 언제나 공부는 놓지 말아야 해... 오늘 (다시) 공부할 건 iterator! undefined를 return하는 건 forEach method 조건이 true 인 값들을 반환하는 건 filter method 으아악 너무 피곤해 운동했는데도 왜 피곤하지... 값들을 먹고 그것들을 다 합친 하나를 반환하는 건 reduce method array를 먹고 new array를 반환하는 건 map method boolean value를 반환하는 건 every와 some every는 callback function이 모!든! element에 대해 true이면 true를 반환 some은 최소한 하나의~ element가 true이면 true를 반환!..
[Javascript] .reduce() method에서 살짝 위기가 찾아옴 지금 const newNumbers = [1, 3, 5, 7]; const newSum = newNumbers.reduce((accumulator, currentValue) => { console.log('The value of accumulator: ', accumulator); console.log('The value of currentValue:', currentValue); return accumulator + currentValue; }, 10) console.log(newSum); 이 코드를 내가 짰는데... 이렇게 놓고 보니까 별로 안 어렵네?ㅋㅋㅋㅋㅋㅋ 괜찮은 것 같다 https://discuss.codecademy.com/t/logic-behind-foreach-and-callback-func..
[Javascript] higher-order function은 뭔데? https://medium.com/functional-javascript/higher-order-functions-78084829fff4 Higher Order Functions Closures, function factories, common factory pattern functions medium.com 아 정리 잘 되어 있는 것 같은데 영어로 되어 있어서 읽기 싫다ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ 그래도 이따가 스르륵 읽고 정리 함 해 봐야지 아 잠시만 지금 iterator 보고 급 의욕 상실됨 잠시만ㅋㅋㅋㅋㅋㅋㅋ 좀만 쉬다 와서 다시 공부해야겠다 그래도 벌써 한 시간 반 안 쉬고 공부한 건가 대견해~ 고등학교 때랑 비슷하게 돌아왔다 고등학교 때도 한 시간 반 정도 기준으로 끊어서 공부했던 기억... 아닌감..
[Javascript] findIndex() method findIndex method는 겁나 쉽다 const animals = ['hippo', 'tiger', 'lion', 'seal', 'cheetah', 'monkey', 'salamander', 'elephant']; const foundAnimal = animals.findIndex(x => { return x === 'elephant'; }) const startsWithS = animals.findIndex(x => { return x[0] === 's'; }) 대충 이렇게 적으면 조건에 맞는 첫번째 값을 반환해 준다. 이렇게 겁나 쉬운데 이 글을 적는 이유가 무엇인가 하면 findIndex method는 조건에 맞는 값을 찾지 못하면 -1을 반환한다는 것을 기억하기 위함이다... 기본적인 문법은..