Day 15: Advanced Functions & Scope

Intermediate Function Usage

In JavaScript, functions can be used just like other values. We can assign them to variables and pass them to other functions as arguments. We can pass a named function or an anonymous inline function. A typical function that takes a function as an argument is setTimeout, which is used to run a certain action after a set time period. Arrow Functions were also introduced in ES6 which give us a way to write cleaner (and cooler) looking code 🤓.

Arrow function example.


Scope refers to which variables are accessible in specific functions. Every variable has a scope that it can be used inside, outside of that scope we cannot use that variable. Variables that are declared inside of functions are local to that specific function. Variables declared outside of a function have global scope and can be accessed from anywhere. We should use const and let to declare our variables instead of var as they are block-scoped instead of function-scoped. Block scoped elements are local to functions, as well as loops and if-else statements.

Scope example


Finally back at it! Sorry for the long break between articles, I have been caught up in the holidays! Boot camp is back and I will be returning to my posts with all the content I have learned. I also secured my first job as a Front End Web Developer, so I am super excited to build something awesome for the client! ✌🏼



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Brent Carey

Brent Carey

Web Developer Studying at BrainStation 🧑🏽‍💻, documenting all the cool things I learn 📚, anime inspiration too 🦸🏽‍♂️🦹🏽‍♂️.