728x90 반응형 SMALL 전체 글380 chapter 5) callback ### Declarative Function Example - **`callThreeTimes` Function**: This is a higher-order function because it takes another function as its argument (`callback`). It runs a loop three times, calling the `callback` function on each iteration with the current index `i` as its argument. - **`print` Function**: A simple function that logs the current iteration number to the console, appending "call o.. 2024. 12. 10. chapter 5) expansion operator ### Default Parameters in Functions The `earnings` function calculates and logs an employee's earnings information. It takes three parameters: `name`, `wage`, and `hours`. The latter two have default values of `8590` (interpreted as hourly wage in won) and `40` (hours worked), respectively. - **First Call**: `earnings('cloud')` only specifies the `name` parameter. Since `wage` and `hours` are no.. 2024. 12. 9. chapter 5) fix name conflict issue ### Variable Scoping Demonstrated - **Global Scope**: Initially, a variable `pi` is declared with the value `3.14`. This variable has a global scope, meaning it can be accessed anywhere in the script. - **Block Scope**: The script then enters a block (denoted by curly braces `{}`). Inside this block, another `pi` variable is declared with the value `3.141592`. This declaration of `pi` is separat.. 2024. 12. 8. chapter 5) function_type ### Anonymous Function - **Anonymous Function**: Assigned to `const func`. Anonymous functions are functions without a name. This function logs several messages to the console when called. - `func()` is called twice, demonstrating that the function can be invoked like any named function. - `typeof func` shows that `func` is a function, and `console.log(func)` prints the function's definition to .. 2024. 12. 7. 이전 1 ··· 14 15 16 17 18 19 20 ··· 95 다음 728x90 반응형 LIST