본문 바로가기
ELSE

Quora 모음 n++ 보다 ++n 쓰기 등

by JiGyeong 2022. 7. 20.

let n = 4;

let k = n++; // k=4, n=5

let k = ++n; // k=6, n=6

 

개발자가 말하고자 하는 바가 명확해진다.

반복문에선 n++ 보다 ++n 의 성능이 더 좋다.(int 형은 컴파일러 최적화로 별차이 없고, iterator의 경우 효과가 있다)

 

참고

https://qr.ae/pvkStC

 

Why is n++ faster than n=n+1?

Mario Galindo Queralt's answer: I see that others have explained you why [code ]n++[/code] is faster than [code ]n=n+1[/code]. I, will not repeat that. However I want to say you that [code ]++n[/code] could be even faster. This is because [code ]n++[/code]

www.quora.com

 

 

프론트엔드 개발자로서 고려해야될 것

https://qr.ae/pvkSri

 

Why are JavaScript and front-end engineers paid so high even though their jobs are so easy?

Nick Brombal's answer: > “Why are Javascript and Front end engineers paid so high even though their jobs are so easy?” Individuals who find front-end development to be easy generally fall into one of two categories. 1. Those who are gifted. 2. Those wh

www.quora.com