blocks can be labelled for the break statement, and loops for continue. Although goto is a reserved word, goto is not implemented in JavaScript. loop1: for (var a = 0; a < 10; ++a) { if (a === 4) break loop1; // Stops after the 4th attempt console.log('a = ' + a); loop2: for (var b = 0; b < 10; ++b) { if (b === 3) continue loop2; // Number 3 is skipped if (b === 6) continue loop1; // Continues the first loop, 'finished' is not shown console.log('b = ' + b); } //end of loop2 console.log('finished'); } //end of loop1 block1: { console.log('Hello'); // Displays 'Hello' break block1; console.log('World'); // Will never get here } goto block1; // Parse error. Functions A function is a block with a (possibly empty) parameter list that is normally given a name. A function may use local variables. If you exit the function without a return statement, the value is returned. function gcd(number1, number2) { if isNaN(number1*number2) throw TypeError("Non-Numeric arguments not allowed."); number1 = Math.round(number1); number2 = Math.round(number2); let difference = number1 - number2; if (difference === 0) return number1; return difference > 0 ? gcd(number2, difference) : gcd(number1, -difference); } console.log(gcd(60, 40)); // 20 //In the absence of parentheses following the identifier 'gcd' on the RHS of the assignment below, //'gcd' returns a reference to the function itself without invoking it. let mygcd = gcd; // mygcd and gcd reference the same function. console.log(mygcd(60, 40)); // 20 Functions are first class objects and may be assigned to other variables. The number of arguments given when calling a function may not necessarily correspond to the number of arguments in the function definition; a named argument in the definition that does not have a matching argument in the call will have the value (that can be implicitly cast to false). Within the function, the arguments may also be accessed through the object; this provides access to all arguments using indices (e.g. ), including those beyond the number of named arguments. (While the arguments list has a .length property, it is not an instance of ; it does not have methods such as , , etc.) function add7(x, y) { if (!y) { y = 7; } console.log(x + y + arguments.length); }; add7(3); // 11 add7(3, 4); // 9 Primitive values (number, boolean, string) are passed by value. For objects, it is