JavaScript Flashcards

1
Q

How are arrays in JavaScript different to arrays in Java?

A

Arrays in JavaScript are like a Hash Table in memory

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

if you have an array [1,2,3] could you do a[5] = 20

A

Yes it would be [1,2,3, <space>, 20]</space>

If you tried to do this in Java you would get an array out of bounds index

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

How do you add and remove elements from an array in JavaScript?

A

push(value) adds an element
pop() removes the last element

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

In JavaScript, functions are first class citizens what does that mean?

A
  1. Can assign functions to variables
  2. Can pass functions to other functions
  3. Can return functions from functions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Can you do this foo()()?

A

Yes it will call the inner function of foo()

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