js_flashcards_other

(18 cards)

1
Q

How are function declarations hoisted?

A

Fully hoisted: name and body available before definition. Can be called before declaration.

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

Why avoid deeply nested logic?

A

Reduces readability and complexity. Avoid by breaking functions down and using early returns.

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

What is the Single Responsibility Principle (SRP)?

A

A function should have one responsibility and one reason to change. Makes code modular and testable.

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

Advantages of arrow functions?

A

Concise syntax and lexical this binding to avoid context issues.

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

What are template literals?

A

Strings using backticks with interpolation and multiline support.

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

What is modular code and why important?

A

Organized, reusable units. Improves reusability, maintainability, and testing.

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

How does inline caching work?

A

Stores property lookup results for reuse, avoiding repeated lookups.

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

Impact of hidden classes on performance?

A

Optimize property access if objects share shape. Different shapes reduce performance.

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

What are the 7 primitive data types?

A

string, number, boolean, null, undefined, symbol, bigint.

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

What are reference types?

A

Objects, arrays, functions. Complex structures stored by reference.

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

Explain copy by value in JS.

A

Primitives copied independently. Changes do not affect the copy.

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

Explain copy by reference in JS.

A

References copied. Both point to same object. Changes affect all references.

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

Difference between == and ===?

A

== compares after type conversion.
=== compares without conversion. Prefer ===.

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

typeof null result?

A

typeof null === ‘object’ (historical bug).

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

Explain reference counting GC.

A

Counts references. When zero, object reclaimed. Fails with circular refs.

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

Purpose of nullifying references?

A

Set to null to signal GC object no longer needed.

17
Q

Why avoid unnecessary objects?

A

Too many temps strain GC. Reuse objects when possible.

18
Q

What is an object pool?

A

Reuse pre-initialized objects to reduce GC overhead.