문자
유니코드
유니코드의 바이트 수
a
0x0061
2
≈
0x2248
2
𝒳
0x1d4b3
4
𝒴
0x1d4b4
4
😄
0x1f604
4
보다시피… a나 ≈같은 문자는 2바이트를 차지하고 𝒳, 𝒴, 😄같은 문자는 코드값이 더 길고 4바이트를 차지합니다.… 여기서 중요한 것은 length는 4바이트 문자를 2바이트 문자 2개로 취급한다는 것입니다. 4바이트를 하나로 묶어서 취급해야 하므로 올바르지 않은 결과입니다.… 기본적으로는 정규 표현식도 4바이트의 '긴 문자’를 2바이트 문자 2개로 취급합니다. 문자열의 경우처럼 이런 방식은 잘못된 결과로 이어질 수 있습니다.… 문자열과 다르게 정규 표현식에는 이런 문제를 해결할 수 있는 u 플래그가 있습니다. u 플래그를 사용하면 정규식은 4바이트 문자를 올바르게 처리합니다.
Sets.For instance, [eao] means any of the 3 characters: 'a', 'e', or 'o'.
That’s called a set.… That’s easy with unicode properties: [\p{Alpha}\p{M}\p{Nd}\p{Pc}\p{Join_C}].
Let’s decipher it.… [^\s] – any non-space character, same as \S.… ,
right half of 𝒳 (2),
left half of 𝒴 (3),
right half of 𝒴 (4).… That’s the formal reason for the error.
조절점이 4개인 경우 카스텔조 알고리즘은 다음과 같습니다.
조절점 1과 2, 2와 3, 3과 4를 연결하는 선분을 만듭니다.… 조절점이 2개일 때:
P = (1-t)P1 + tP2
조절점이 3개일 때:
P = (1−t)2P1 + 2(1−t)tP2 + t2P3
조절점이 4개일 때:
P = (1−t)3P1… + 3(1−t)2tP2 +3(1−t)t2P3 + t3P4
위 식들은 벡터 방정식입니다.… x = (1−t)2x1 + 2(1−t)tx2 + t2x3
y = (1−t)2y1 + 2(1−t)ty2 + t2y3
x1과 y1, x2와 y2, x3과 y3엔 세 조절점의 x, y… x = (1−t)2 * 0 + 2(1−t)t * 0.5 + t2 * 1 = (1-t)t + t2 = t
y = (1−t)2 * 0 + 2(1−t)t * 1 + t2 * 0 = 2(1
And it can’t be both version 1 and 2.… to 2, from 2 to 3, from 3 to 4 etc.… by step, for every intermediate version (2 to 3, then 3 to 4).… , but right now in 2.0 there isn’t.… The best manual is the specification, the current one is 2.0, but few methods from 3.0 (it’s not much
In regular expressions that’s (\w+\.)… Let’s add parentheses for them: <(([a-z]+)\s*([^>]*))>.… Then in result[2] goes the group from the second opening paren ([a-z]+) – tag name, then in result[3]… We can’t get the match as results[0], because that object isn’t pseudoarray.… That’s used when we need to apply a quantifier to the whole group, but don’t want it as a separate item
부분 문자열 "id"는 위치 1에서 처음 등장하는데, 두 번째 인수에 2를 넘겨 "id"가 두 번째로 등장하는 위치가 어디인지 알아봅시다.… str이 str2보다 작으면 음수를 반환합니다.
str이 str2보다 크면 양수를 반환합니다.
str과 str2이 같으면 0을 반환합니다.… 이를 이용하면 베이스 글자 S 뒤에 '윗 점’을 나타내는 유니코드 문자(\u0307)를 붙여 Ṡ를 만들 수 있습니다.… Ṡ에 '아래 점’을 나타내는 유니코드 문자(\u0323)를 추가해서 ‘S 위와 아래에 점이 붙게’ 해봅시다.… Ṩ를 나타내는 유니코드 \u1e68로 말이죠.
\d ('digit(숫자)'의 ‘d’)
숫자: 0에서 9 사이의 문자
\s ('space(공백)'의 ‘s’)
스페이스, 탭(\t), 줄 바꿈(\n)을 비롯하여 아주 드물게 쓰이는 \… 예를 들어 \d\s\w는 1 a처럼 ‘숫자’ 뒤에 ‘공백 문자’ 뒤에 '단어에 들어가는 문자’를 의미합니다.
정규 표현식에 일반 기호와 문자 클래스를 같이 사용할 수 있습니다.… 이럴 때 사용하는 것이 s입니다.… [\s\S] 패턴의 문자 그대로의 뜻은 '공백 문자 또는 공백 문자가 아닌 문자’입니다. 결국은 모든 문자라는 뜻이죠.… \d – 숫자
\D – 숫자가 아닌 문자
\s – 스페이스, 탭, 줄 바꿈 문자
\S – \s를 제외한 모든 문자
\w – 라틴 문자, 숫자, 밑줄 '_'
\W – \w를 제외한 모든
But not \bHell\b (because there’s no word boundary after l) and not Java!… \b (because the exclamation sign is not a wordly character \w, so there’s no word boundary after it).… For example, the pattern \b\d\d\b looks for standalone 2-digit numbers.… In other words, it looks for 2-digit numbers that are surrounded by characters different from \w, such… Word boundary \b doesn’t work for non-latin alphabets
The word boundary test \b checks that
Let’s see the rest of API, to cover all its abilities.… instead of http://site.com/path.… " – use a response from HTTP-cache, even if it’s stale.… so that there won’t be a lot left for the last onunload request.… We can’t handle the server response if the document is unloaded.
To make clear why that’s helpful, let’s consider a task.… \1.… Similar to that, \2 would mean the contents of the second group, \3 – the 3rd group, and so on.… Don’t mess up: in the pattern \1, in the replacement: $1
In the replacement string we use… a dollar sign: $1, while in the pattern – a backslash \1.
But we need only one word at position 4.… Such simple no-flags case doesn’t interest us here.… For instance, let’s find a word, starting from position 4:… If there’s no word at position lastIndex, but it’s somewhere after it, then it will be found:… match at position 3 (unlike the flag g), but matches at position 4.
Let’s see the asynchronous first, as it’s used in the majority of cases.… Here’s a full example.… → 2 → 3 → … → 3 → 4.… Here’s the rewritten example, the 3rd parameter of open is false:… Once the header is set, it’s set.
It has 3 modes:
If the regexp doesn’t have flag g, then it returns the first match as an array with… That’s an important nuance. If there are no matches, we don’t get an empty array, but null.… The function is called with arguments func(match, p1, p2, ..., pn, offset, input, groups):
match – the… match,
p1, p2, ..., pn – contents of capturing groups (if there are any),
offset – position of the match… This behavior doesn’t bring anything new.
값이 음수일 땐 애니메이션 효과가 중간부터 나타납니다. transition-duration을 2s, 지연 시간을 -1s로 설정하면 애니메이션 효과는 1초가 지난 후 1초 동안 지속됩니다… 첫 번째 조절점: (0,0)
마지막 조절점: (1,1)
중간 조절점들: x가 0과 1 사이에 있어야 함. y엔 제약이 없음
CSS에선 베지어 곡선을 cubic-bezier(x2,… y2, x3, y3)형태로 정의합니다.… 초별로 프로세스가 몇 %씩 진행되는지를 정리하면 다음과 같죠.
0s – -10% (애니메이션이 시작하자마자 바로 첫 번째 단계가 수행됨)
1s – -20%
…
8s – -80%
(… 초별 프로세스 정도는 다음과 같습니다.
0s – 0
1s – -10% (1초가 지난 후에 첫 단계가 수행됨)
2s – -20%
…
9s – -90%
두 번째 인수를 변화 시켜(steps
To be precise, there are 2n-1, where n is the length of the set.… But the engine doesn’t know that.
It tries all combinations of how the regexp (\w+\s?)… E.g. in the regexp (\d+)*$ it’s obvious for a human, that + shouldn’t backtrack.… =(\w+))\1.
Let’s decipher it:
Lookahead ?… That is: we look ahead – and if there’s a word \w+, then match it as \1.
Why?
The idea is that if a user has two pages open: one from john-smith.com, and another one is gmail.com,… then they wouldn’t want a script from john-smith.com to read our mail from gmail.com.… These URLs all share the same origin:
http://site.com
http://site.com/
http://site.com/my/page.html… : .org matters)
https://site.com (another protocol: https)
http://site.com:8080 (another port: 8080)… But if windows share the same second-level domain, for instance john.site.com, peter.site.com and site.com
Let’s say we have a string like +7(903)-123-45-67 and want to find all numbers in it.… A number is a sequence of 1 or more digits \d.… The range: {3,5}, match 3-5 times
To find numbers from 3 to 5 digits we can put the limits into curly… Then a regexp \d{3,} looks for sequences of digits of length 3 or more:… r looks for o followed by zero or one u, and then r.
So, colou?
switch문은 a의 값인 4와 첫 번째 case문의 값인 3을 비교합니다.… 이 값은 첫 번째 case문의 표현식 b + 1을 평가한 값(1)과 일치하죠. 따라서 첫 번째 case문 아래의 코드가 실행됩니다.… 입력한 경우엔 첫 번째 alert문이 실행됩니다.
2를 입력한 경우엔 두 번째 alert문이 실행됩니다.
3을 입력하였더라도 세 번째 alert문은 실행되지 않습니다.… 앞서 배운 바와 같이 prompt 함수는 사용자가 입력 필드에 기재한 값을 문자열로 변환해 반환하기 때문에 숫자 3을 입력하더라도 prompt 함수는 문자열 '3'을 반환합니다.… 그런데 세 번째 case문에선 사용자가 입력한 값과 숫자형 3을 비교하므로, 형 자체가 다르기 때문에 case 3 아래의 코드는 절대 실행되지 않습니다.
So we can’t really render there.… Besides, if you think about it, that’s better performance-wise – to delay the work until it’s really… So let’s fix this.… We can clearly see that the outer element finishes initialization (3) before the inner one (4).… Edge is a bit behind, but there’s a polyfill https://github.com/webcomponents/polyfills/tree/master/packages
So it’s a special character in regexps (just like in regular strings).… Here’s a full list of them: [ \ ^ $ . | ? * + ( ).… That’s also called “escaping a character”.… Here’s how “\d.… That’s why the search doesn’t work!
Math.floor
소수점 첫째 자리에서 내림(버림). 3.1은 3, -1.1은 -2가 됩니다.… Math.ceil
소수점 첫째 자리에서 올림. 3.1은 4, -1.1은 -1이 됩니다.… Math.round
소수점 첫째 자리에서 반올림. 3.1은 3, 3.6은 4, -1.1은 -1이 됩니다.… Math.floor
Math.ceil
Math.round
Math.trunc
3.1
3
4
3
3
3.6
3
4
4
3
-1.1
-2
-1
-1
-1
-1.6
-2… 같은 이유로 2진법 체계에서 2의 거듭제곱으로 나눈 값은 잘 동작하지만 1/10같이 2의 거듭제곱이 아닌 값으로 나누게 되면 무한 소수가 되어버립니다.
10진법에서 1/3을 정확히
Let’s select something.… 2nd child of <p> (that’s the text node " and ", but as the end is not included, so the… Here’s a screenshot of a selection with 3 ranges, made in Firefox:… at maximum 1.… That’s a somewhat complex method.
pow(2, 4) = 2 * pow(2, 3)
pow(2, 3) = 2 * pow(2, 2)
pow(2, 2) = 2 * pow(2, 1)
pow(2, 1) = 2
이렇게 재귀를… 이제 pow (2, 3)가 호출되면 실행 컨텍스트에서 무슨 일이 일어나는지 살펴봅시다.
pow(2, 3).pow (2, 3)를 호출하는 순간, 실행 컨텍스트엔 변수 x = 2, n… Context: { x: 2, n: 3, 다섯 번째 줄 }
pow(2, 3)
x * pow (x, n - 1)을 계산하려면 새로운 인수가 들어가는 pow의 서브 호출(… )
Context: { x: 2, n: 3, 다섯 번째 줄 }
pow(2, 3)
기존 컨텍스트 두 개가 밑에, pow (2, 1)에 상응하는 컨텍스트가… 서브 호출 pow (2, 1)의 결과를 알고 있으므로, 쉽게 x * pow (x, n - 1)를 계산해 4를 반환합니다.
표현식 (1 + 2) * 2에서 괄호로 둘러싼 덧셈 연산자가 먼저 수행되는 것 같이 말이죠.… 이 연산자는 할당(assignment) 연산자라고 불리는데, 우선순위는 3으로 아주 낮습니다.
x = 2 * 2 + 1과 같은 표현식에서 계산이 먼저 이뤄지고, 그 결과가 x에 할당되는… + 2은 평가가 되지만 그 결과는 버려집니다. 3 + 4만 평가되어 a에 할당되죠.… 괄호가 없으면 a = 1 + 2, 3 + 4에서 +가 먼저 수행되어 a = 3, 7이 됩니다.… 할당 연산자 =는 쉼표 연산자보다 우선순위가 높기 때문에 a = 3이 먼저 실행되고, 나머지(7)는 무시되죠. (a = 1 + 2), 3 + 4를 연산한 것처럼 될 겁니다.
예시:
Math.max(arg1, arg2, ..., argN) – 인수 중 가장 큰 수를 반환합니다.… Object.assign(dest, src1, ..., srcN) – src1..N의 프로퍼티를 dest로 복사합니다.… 배열 [3, 5, 1]이 있고, 이 배열을 대상으로 Math.max를 호출하고 싶다고 가정해봅시다.… Math.max (arr[0], arr[1], arr[2]) 처럼 배열 요소를 수동으로 나열하는 방법도 있긴 한데, 배열 길이를 알 수 없을 때는 이마저도 불가능합니다.… 문자열에 for..of를 사용하면 문자열을 구성하는 문자가 반환됩니다. ...str도 H,e,l,l,o가 되는데, 이 문자 목록은 배열 초기자(array initializer) [.
G는 G와 같습니다.
l은 l과 같습니다.
o는 e보다 크기 때문에 여기서 비교가 종료되고, o가 있는 첫 번째 문자열 'Glow'가 더 크다는 결론이 도출됩니다.… 위 비교 결과는 논리에 맞지 않아 보입니다. (3)에서 null은 0보다 크거나 같다고 했기 때문에, (1)이나 (2) 중 하나는 참이어야 하는데 둘 다 거짓을 반환하고 있네요.… 이런 이유 때문에 (2)는 거짓을 반환합니다.… (1)과(2)에선 undefined가 NaN으로 변환되는데(숫자형으로의 변환), NaN이 피연산자인 경우 비교 연산자는 항상 false를 반환합니다.
undefined는 null이나… undefined와 같고, 그 이외의 값과는 같지 않기 때문에 (3)은 false를 반환합니다.
For instance, let’s request a script that doesn’t exist:… Crossorigin policy.There’s a rule: scripts from one site can’t access contents of the other site.… So, e.g. a script at https://facebook.com can’t read the user’s mailbox at https://gmail.com.… If we’re using a script from another domain, and there’s an error in it, we can’t get error details.… Let’s add it.
It’s random to prevent proxies from caching any following communication.… , 부라우저에서 페이지 종료)
1009 – 메시지가 너무 커서 처리하지 못함
1011 – 서버 측에서 비정상적인 에러 발생
…기타 등등…
코드 전체 목록은 RFC6455, §7.4.1에서… 통신 중
2 – “CLOSING”: 커넥션 종료 중
3 – “CLOSED”: 커넥션이 종료됨
채팅 앱 만들기.브라우저의 웹소켓 API와 Node.js에서 제공하는 웹소켓 모듈을… Here we’ll use Node.js, but you don’t have to.… ://site.com goes to the main HTTP-server.
Otherwise, if the first digit is 2, then the next must be [0-3].… If we glue minutes and seconds together, we get the pattern: [01]\d|2[0-3]:[0-5]\d.… The alternation | now happens to be between [01]\d and 2[0-3]:[0-5]\d.… to allow [01]\d OR 2[0-3].… Let’s correct that by enclosing “hours” into parentheses: ([01]\d|2[0-3]):[0-5]\d.
자세한 내용은 앵커 ^와 $의 여러 행 모드, 'm' 플래그에서 다룰 예정입니다.
s
.이 개행 문자 \n도 포함하도록 ‘dotall’ 모드를 활성화합니다.… 자세한 내용은 문자 클래스에서 다룰 예정입니다.
u
유니코드 전체를 지원합니다. 이 플래그를 사용하면 서로게이트 쌍(surrogate pair)을 올바르게 처리할 수 있습니다.… 자세한 내용은 유니코드: 'u' 플래그와 \p{...} 클래스에서 다룰 예정입니다.
y
문자 내 특정 위치에서 검색을 진행하는 ‘sticky’ 모드를 활성화 시킵니다.… part of the string before the match
$'
inserts a part of the string after the match
$n
if n is a 1-… 정규 표현식은 패턴과 선택적으로 사용할 수 있는 플래그 g, i, m, u, s, y로 구성됩니다.
Events Level 3 is in the works and is mostly compartible with Pointer Events level 2.… Also there are 3 additional pointer events that don’t have a corresponding mouse... counterpart, we’ll… Where unsupported, e.g. for a mouse, it’s always 1.
height – the height of the area where the pointer… Where unsupported, it’s always 1.
pressure – the pressure of the pointer tip, in range from 0 to 1.… After we do that, the events will work as intended, the browser won’t hijack the process and doesn’t
There’s one more thing to keep in mind.… Let’s see more of them.… The graph for x=1.5:
In action for x=1.5:
Reversal: ease*.So we… That’s great.… Gets a time fraction from 0 to 1, returns the animation progress, usually from 0 to 1.
draw – the function
On the other hand, we should keep in mind that the mouse pointer doesn’t “visit” all elements along the… But that’s not the case!… So, let’s use mouseover/mouseout.… Let’s filter them out.… Fast or slow – doesn’t matter.
It doesn’t matter how.… Usually that’s done with z-index.… But then there’s a problem.… Let’s cover a few.… > won’t do anything.
It’s the quote ".… That’s probably not what we expected, but that’s how it works.… 'i', so there’s no match.… Then there’s a space in the pattern, it matches.
Then there’s \d+?.… That’s what’s going on:
First the regexp finds a link start <a href=".
It’s non-standard, exists for historical reasons.… Other elements, like <img>, can’t host shadow tree.… There’s no way to access them.… Style rules from the outer DOM don’t get applied.… DOM: https://dom.spec.whatwg.org/#shadow-trees
Compatibility: https://caniuse.com/#feat=shadowdomv1
Shadow
위 예시를 실행하면 1과 2만 출력되고 3은 출력되지 않습니다.
이유는 for..of 이터레이션이 done: true일 때 마지막 value를 무시하기 때문입니다.… 마지막 줄, generator.next(4)에서 제너레이터가 다시 시작되고 4는 result에 할당됩니다(let result = 4).… 두 번째 .next(4)는 첫 번째 yield의 결과가 될 4를 제너레이터 안으로 전달합니다. 그리고 다시 실행이 이어집니다.… 실행 흐름이 두 번째 yield에 다다르고, 산출 값("3 * 3 = ?")이 제너레이터 호출 결과가 됩니다.… "2 + 2 = ?"의 산출 값이 에러를 발생시키는 경우를 살펴봅시다.
Let’s start with a simple example.… There’s a side-effect though.… The browser can’t free it.… That’s handy to upload it somewhere.… /niklasvh/html2canvas.
Please note: there’s currently no way for fetch to track upload progress.… But usually it’s at place.
Call await reader.read() until it’s done.… That’s important, because after the response is consumed, we won’t be able to “re-read” it using response.json… Unfortunately, there’s no single method that concatenates those, so there’s some code to do that:
We… That’s even simpler.
코드를 작성하고 f(1)이 제대로 동작하는지 확인합니다. 제대로 동작하네요. 그런데 f(2)를 테스트해 보니 제대로 동작하지 않습니다.… assert.equal(value1, value2)
기능을 제대로 구현했다면 it 블록 내의 코드 assert.equal(value1, value2)이 에러 없이 실행됩니다.… 지금 상황에선 pow(2,3)가 8이 아닌 undefined를 반환하기 때문에 에러가 발생합니다.… assert.equal(value1, value2) – value1과 value2의 동등성을 확인합니다(value1 == value2).
assert.strictEqual(value1… , value2) – value1과 value2의 일치성을 확인합니다(value1 === value2).
assert.notEqual, assert.notStrictEqual – 비
For the start, let’s find the price from the string like 1 turkey costs 30€.… Check if Y is immediately after X (skip if isn’t).… That’s only possible if patterns Y and Z aren’t mutually exclusive.
For example, \d+(?=\s)(?… =.*30) looks for \d+ only if it’s followed by a space, and there’s 30 somewhere after it:… That’s natural: we look for a number \d+, while (?
It’s very easy to open a popup.… That’s a bit tricky.… Otherwise, e.g. if the main window is from site.com, and the popup from gmail.com, that’s impossible… There’s also window.onscroll event.… But they don’t work all the time.
위 예시는 아래와 같은 순서로 실행됩니다.
1초 후 최초 프라미스가 이행됩니다. – (*)
이후 첫번째 .then 핸들러가 호출됩니다. –(**)
2에서 반환한 값은 다음 .then… result가 핸들러 체인을 따라 전달되므로, alert 창엔 1, 2, 4가 순서대로 출력됩니다.… 두 번째 핸들러((**))는 2를 출력하고 동일한 과정이 반복됩니다.
따라서 얼럿 창엔 이전 예시와 동일하게 1, 2, 4가 차례대로 출력됩니다.… 위 예제에서 가장 깊은 곳에 있는 중첩 콜백은 script1, script2, script3 안에 있는 변수 모두에 접근할 수 있습니다.… 위 예시에서 resolve(2)는 1초 후에 호출됩니다((**)). 호출 후 결과는 체인을 따라 아래로 전달됩니다.
Luckily, we don’t have to.… It’s kind of “virtual”. That’s how things are shown.… For example, here the menu item is inserted dynamically after 1 second, and the title changes after 2… Please note: there’s no slotchange event after 2 seconds, when the content of slot="title"… That’s because there’s no slot change.
. – (1)
Symbol.asyncIterator는 프라미스를 반환하는 메서드인 next()가 구현된 객체를 반환해야 합니다. – (2)
next()는 async 메서드일 필요는… 다만, async를 사용하면 await도 사용할 수 있기 때문에, 여기선 편의상 async메서드를 사용해 일 초의 딜레이가 생기도록 했습니다. – (3)
반복 작업을 하려면 ‘for… 이제 1초의 간격을 두고 값을 얻을 수 있습니다.
실제 사례.지금까진 아주 간단한 예시들만 살펴보며, async 제너레이터에 대한 기초를 다졌습니다.… 클라이언트는 https://api.github.com/repos/<repo>/commits 형태의 URL로 요청을 보냅니다.… 헤더에서 https://api.github.com/repositories/93253246/commits?page=2형태의 URL만 추출하기 위해 정규표현식을 사용하였습니다.
Please evade mistypes: it’s KeyZ, not keyZ.… For instance, Shift or F1 or others.… F1
F1
Backspace
Backspace
Backspace
Shift
Shift
ShiftRight or ShiftLeft
Please note that event.code… That’s a side-effect of the strict filter checkPhoneKey.… There’s no keyboard event for it, because it’s often implemented on lower level than OS.
콘솔 창에 구문(statement)을 입력하고 실행하면 아랫줄에 실행 결과가 출력됩니다.
1+2를 입력하면 3이 출력되고, hello("debugger")를 입력하면… 중단점.예시 페이지 내부에서 무슨 일이 일어나는지 자세히 살펴봅시다. hello.js를 소스 코드 영역에 띄우고 네 번째 줄 코드 좌측의 줄 번호, 4를 클릭합시다.… 코드가 아닌 줄 번호 4에 마우스 커서를 옮긴 후 클릭해야 합니다.
축하합니다! 중단점을 성공적으로 설정하셨습니다. 줄 번호 8도 클릭해 중단점을 하나 더 추가해봅시다.… 줄 번호 4와 8이 파란색으로 바뀐 게 보이시죠?… Google에서 제공하는 개발자 도구 공식 매뉴얼은 https://developers.google.com/web/tools/chrome-devtools에서 확인할 수 있습니다.
인덱스 1이 가리키는 요소부터 시작해 요소 한 개(1)를 지웠습니다.… 메서드를 호출하면 arr에 속한 모든 요소와 arg1, arg2 등에 속한 모든 요소를 한데 모은 새로운 배열이 반환됩니다.… 재정렬 후 배열 요소가 1, 15, 2가 되었습니다. 기대하던 결과(1, 2, 15)와는 다르네요. 왜 이런 결과가 나왔을까요?
요소는 문자열로 취급되어 재 정렬되기 때문입니다.… 두 번째 호출 시, sum = 1 이고 여기에 배열의 두 번째 요소(2)가 더해지므로 결과는 3이 됩니다.… sum
current
result
첫 번째 호출
0
1
1
두 번째 호출
1
2
3
세 번째 호출
3
3
6
네 번째 호출
6
4
10
다섯번째 호출
10
5
인수가 세 개이므로 sum.length = 3 입니다.
curried(1)(2)(3)이 호출되는 과정은 다음과 같습니다.… 첫 번째 curried(1) 을 호출할때 1을 렉시컬 환경에 기억하고 curried(1) 이 pass 래퍼를 반환합니다.
pass래퍼가 (2)와 함께 호출됩니다.… 이전의 인수인 (1)을 가져서 (2)와 연결하고curried (1, 2)를 함께 호출합니다.… 인수의 개수는 아직 3보다 작기때문에 curry는 pass를 반환합니다.
pass 래퍼가 다시 (3)과 함께 호출됩니다.… 다음 호출인 pass(3)가 이전의 인수들인 (1, 2)를 가져오고 3을 추가하고 curried(1, 2, 3) 호출을 합니다 – 여기에 3인수는 마지막으로, 원래의 함수에 전달됩니다
So technically we don’t have to use URL. But sometimes it can be really helpful.… …”.Let’s say we want to create a url with given search params, for instance, https://google.com/search… So there’s URL property for that: url.searchParams, an object of type URLSearchParams.… A natural question is: “What’s the difference between encodeURIComponent and encodeURI?… That’s easy to understand if we look at the URL, that’s split into components in the picture above:
50 개의 검색 결과만 보기