Javascript Flashcards
Functions vs methods
Functions return a value procedures do not
A method is similar to a function but is part of a class. The term method is exclusively used in object oriented programming
What is the difference between a variable that is null, undefined or undeclared
Undeclared - when you try and use a variable that isn’t declared
Undefined - declared it but not assigned a value, object array exists but nothing at the key/index, function exists but does not return anything, falsy
Null - null has a value and its value is null. Null is a nothing value, not a zero, not an empty string/object/array, falsy
Explain hoisting
All variables (var) are declared at the top of any given function scope whether you like it or not includes function deceleration
Parameter / argument
Parameter- is the variable in the declaration of a function
Void return Tax(int tax)
Argument - is the actual value of this variable that gets passed into the functional
Tax = returnTax(tax)
IIFE
Immediately invoked function expression
To make a function an IIFE wrap it in brackets to make it an exception
(function foo() {}())
I would use this to control variable scope
Describe event bubbling
Inverse of an event delegation. Also known as propagation, events on an element will “bubble up” and also fire on all parents
What’s the difference between “target” and” current target”
Current target = element with the listener attached
Target = the actual element that triggered it
Explain event delegation
Is event listeners fire not only on a single dom element but on all its descendants
What is the difference between == and ===
== checks for equality
=== checks for equality and type
How would you go about checking for null, undefined, undeclared
Undeclared - finds you except when assigning a value
Undefined - === undefined
Null - === null