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
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
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
4
Q
In JavaScript, functions are first class citizens what does that mean?
A
- Can assign functions to variables
- Can pass functions to other functions
- Can return functions from functions
5
Q
Can you do this foo()()?
A
Yes it will call the inner function of foo()