함수 호출
-
[부스트코스] JavaScript -FE(4)부스트코스 코딩일지/DB 연결 웹 앱 2020. 2. 22. 00:05
자바스크립트 함수의 호출에 대해 공부해봅시다! 함수 호출 스택 1) function printName(firstname) { var myname = "jisu"; return myname + " ," + firstname; } function run(firstname) { firstname = firstname || "Youn"; var result = printName(firstname); console.log(result); } run(); 예제의 실행 순서를 살피어 봅시다. 1. run()이 읽힙니다. 2. run() 함수가 실행되게 되고, firstname 인자에는 undefined라는 값이 할당됩니다. 3. firstname은 undefined이기 때문에 "Youn"으로 재할당됩니다. (>> u..