Loading topic
var, let, and const declare variables, and how to call a function with arguments. It covers the oldest and most common way to define a function: the function declaration.2 min readlet and const declare variables, and how to call a function with arguments. It also builds on the previous chapter's point that functions are values.2 min readvar, let, and const differ, and that you have read the previous two chapters on function declarations and function expressions. The question here is practical: can you call a function on a line above the one where you defined it? The answer depends on which fo3 min readconst and let bindings behave. In the previous chapter, the function expressions were anonymous. You can also give a function expression its own name. That name behaves differently from the variable that holds the function, and 2 min readconst. Arrow functions are a shorter way to write a function expression. This chapter covers only their syntax: how to write parameters, and when the function returns a value without the `retu2 min readreduce. Default and rest parameters behave the same in all three function forms.2 min readsetTimeout. It explains how JavaScript decides what this refers to, because regular functions and arrow functions decide it in different ways.2 min readarguments object, the reason arrow functions have no arguments of their own, and the replacement you should use in new code.2 min readthis works in regular and arrow functions, and that you have used objects and the new keyword at least once. It explains what new needs from a function and why arrow functions don't meet those needs.2 min readthis is set in regular functions, where it depends on the call site, and in arrow functions, where it is taken from the surrounding scope. Here you will use those rules to choose a function form in three places where it matters: object methods, callbacks, 2 min readlet and const create block scope, and how a returned inner function can keep using variables from its outer function (a closure).2 min readlet and const are scoped to blocks. A block is any code between { and } that is not a function body. Examples are the bodies of if, for, and while, or a bare { }.2 min readthis is bound in regular and arrow functions, and why arrows have no arguments object and no constructor behavior. The goal here is to turn those rules into a 2 min read