Download as PDF, PPTX













This document discusses JavaScript variables, functions, and objects. It covers JavaScript datatypes like numbers, strings, and objects. It describes variable scope and how variables are hoisted or moved to the top of their function. It also discusses how functions can be defined and used as variables. Global objects like the window object are described. Finally, it provides examples of defining basic functions and using objects with properties and methods.
Introduction to the concepts of variables and functions in JavaScript presented by Jussi Pohjolainen at Tampere University.
Overview of data types in JavaScript: Numbers, Boolean, String, Null, Undefined, Object, and Function.
Explanation of global and local variable scopes, emphasizing that JavaScript lacks block statement scope.
Introduction to hoisting in JavaScript—variables are moved to the top of their scope.
Demonstration of variable hoisting with examples, showing that uninitialized variables log as undefined.
Further hoisting examples explaining behavior when using variables before they are defined.
Illustrates how local variables can override global variables within functions, impacting output.
Explains how local variables can shadow global variables, resulting in 'undefined' outputs.
Description of global variables as properties of the global object, specifically in web contexts.
Demonstrates the creation and use of objects in JavaScript, including example functions for car types.
Simple function definition in JavaScript showcasing how to define and call a function to add numbers.
Shows how functions can be assigned to variables, enhancing flexibility in function definition.
Details on defining functions using named function expressions and their behavior when called.