JavaScript
This is based on w3schools JavaScript guide, and handpicked to examples and explanations which I think will greatly benefit for understanding the OSWE course.
Functions
In JavaScript there are 2 main types of functions you need to know. Declaration or function expression.
Declared functions
Declared functions are as follow. [ they are only for execution when invoked ] will not automatically execute. //semicolons are used to separate executable JavaScript statements.
Function Expressions

Function expressions can be stored in a variable and they are defined using an expression. This type of function is also called anonymous function (a function without a name)
The Function() Constructor
In previous examples, JavaScript functions are defined with the function keyword. But functions can also be built with function constructor called Function()
Function Hoisting
Hoisting is JavaScript's default behavior of moving all declarations to the top of the current scope. So the variable can be defined after being called. Functions can also be called first before declaring them.
Self-Invoking Functions or Immediately Invoked Function Expression.
A self-invoking expression is invoked (started) automatically, without being called. Function expressions will execute automatically if the expression is followed by ().
*Note: You cannot self-invoke a function declaration. You have to add parentheses around the function to indicate that it is a function expression:
Arrow Functions
It allows a short syntax for writing function expressions. You don't need function keyword the return keyword and the curly brackets.
Callbacks
Callbacks are functions passed as an argument to another function.
Instead of passing the name of a function, you can pass a whole function. [function expression]
Another example of opening a file. And only displaying it after the file has fully loaded.
Last updated
Was this helpful?