Javascript Flashcards

1
Q

Functions vs methods

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the difference between a variable that is null, undefined or undeclared

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Explain hoisting

A

All variables (var) are declared at the top of any given function scope whether you like it or not includes function deceleration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Parameter / argument

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

IIFE

Immediately invoked function expression

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe event bubbling

A

Inverse of an event delegation. Also known as propagation, events on an element will “bubble up” and also fire on all parents

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What’s the difference between “target” and” current target”

A

Current target = element with the listener attached

Target = the actual element that triggered it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Explain event delegation

A

Is event listeners fire not only on a single dom element but on all its descendants

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the difference between == and ===

A

== checks for equality

=== checks for equality and type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How would you go about checking for null, undefined, undeclared

A

Undeclared - finds you except when assigning a value

Undefined - === undefined

Null - === null

How well did you know this?
1
Not at all
2
3
4
5
Perfectly