javascriptlesson3
javascriptlesson3
What is a Function?
o Functions can be called when needed, making your code modular and easy to maintain.
o Functions help break down complex problems into smaller, manageable tasks.
o Functions can be reused throughout your program, saving time and reducing code
duplication.
What is this?
o In JavaScript, this refers to the object that is executing the current function.
o Global context: In the global scope, this refers to the global object (in browsers, it's
window).
Example: