최근에 async-await 원리에 대해 공부하다 apply 함수를 보곤 뭐였지? 라는 궁금증이 들어 공부했고 짧겠지만 간단하게 정리하겠습니다.
apply, call은 함수를 호출하는 방법입니다. 익히 알고 있는 함수() 방법말고도 apply와 call을 통해 아래와 같이 함수를 호출할 수 있습니다.
한 번은 정리하고 싶던 글이였습니다. 배열, 객체, map, set에 대해 위에 쓴 forEach, for in, for of가 어떻게 동작하는지 살펴보겠습니다.
최근 TypeScript 공부 중 Symbol 이란게 보여서 정리합니다.
Symbol은 원시 자료형( Primitive data type)
Symbol은 ES 6에서 추가 된 자료형입니다. 자바스크립트에서 Boolean, string, number, null, undefined와 같이 객체와 메소드가 아닌 데이터입니다.
문법적으로 어떻게 쓰나?
JavaScript 객체의 property를 접근 하는 방법에는 []와 . 을 사용하는 방법이 있습니다. 가령 아래와 같이 a라는 객체가 있다면 속성에 접근하는 방법이 두 가지가 있는거죠
var a = { b : 1, c : 2}
console.log(a["b"] + ' vs ' + a.b) // 1 vs 1
쬐끔 알고 있던 Closure를 최근에 좀 더 알게 되었고, 음.. 근데 언제? 무슨 이유로 개발할 때 Closure를 쓸까 궁금해서 찾아보게 되었습니다. 검색해서 찾은 여러 글 들 중에 고개를 끄덕거린…
ES 5에서 추가 된 몇몇 배열 메소드를 알아보자. 메소드를 잘 알고 있으면, 개발하는 시점에 이땐 이런 메소드를 쓰면 되겠군? 하고 바로바로 적용할 수 있다.
아래 6가지 메소드를 소개하기 전에 사용할 배열 데이터를 먼저 정의하자. 순간 머리속에 떠오른게 과일이라 아래와 같이 배열을 정의하며, 6개 메소드 테스트에 모두 동일하게 아래 데이터를 활용한다.
var arr = [“tomato”, “banana”, “strawberry”…
최근 회사 내부에서 제품의 품질에 대해 시끄럽더니, UT에 대한 중요성이 부각되었다. 나 역시 Node 소스에 대한 UT는 어떻게 하는지 궁금해서 이 글을 쓴다.
Node JS로 작성한 코드의 UT는 mocha를 많이 쓴다. 비교할 것도 없이 인터넷에 올라온 포스팅을 보면 압도적으로 mocha가 많아 선택에 많은 시간을 소요하진 않았다.
시작은 mocha 설치부터
사실 자바스크립트의 Promise는 접한지 조금 되었는데, 더 오래 기억할 겸, 정리해본다.
1. 비동기와 callback hell
자바스크립트에서 비 동기 함수를 호출할 땐, 보통 callback 함수를 등록하고 callback 함수 내부에서 작업을 한다. 문제는 개발을 하다보면 함수 내부에서 또 다른 함수들을 호출하는 경우가 있다. 아래 예제는 callbackHell 이라는 함수가 내부에서 비 동기 함수 3개를 호출하는 코드로, 실제…
자바스크립트를 공부하다 보면 ECMA Script, ES5, ES6 와 같은 용어를 접하게 된다. 대~~~~충 알고 있었는데 구체적으로 알고 넘어가보자.
ECMA Script란..?
자바스크립트는 1990년대 Netscape 회사의 Brendan Eich 라는 사람에 의해 최초 개발되었다. 자바스크립트가 잘 되자, MS에서 Jscript라는 언어를 개발해 IE에 탑재하였는데, 이 두 스크립트가 너무…
오늘 개발 중에 갑자기 에러가 발생한다. 코드를 본다. 음..? 왜..? 코드를 간단히 추려 정리하면 아래 코드와 같다.