JS Questions Flashcards Preview

Full Stack Interview Questions > JS Questions > Flashcards

Flashcards in JS Questions Deck (17):
1

Lexical Scope

A variable defined outside of it’s function declaration is accessible by that function

2

Execution Context

A stack frame. The current code being executed.

3

Lexing time

JS compiles code immediately before execution let a =2 is split to let a (declaration) and a = 2 (instantiation)

4

Currying

A function that returns a function

5

How can you do Mutation Avoidance in js

Spread operator, object.assign, slice vs splice (slice returns a shallow copy)

6

Define Hoisting

moves all declarations to top of execution scope after lexing (splitting declarations vs instantiations) and listing them at the top

7

How does Inheritance work

based on prototype chain, goes all the way up to null, prototype has list of methods for that object

8

How does JS do Async

The event loop uses the call stack and callback queue to provide asynchronous behavior.

9

List Map vs ForEach differences

Map returns a new array. Each execute a function with current element as function arg

10

Function vs arrow() => { …

the arrow function isn’t hoisted, arrow is bounded lexically, function is bound execution context

11

List the differences between const let var

var is global scoped, const let block scoped (open and closed curly braces). var can be redeclared, const, let cannot. Let can be reassigned.

12

Async iterator

await in a for of loop

13

=== vs ==

Triple compares type and values. Double compares values.

14

What is Coercion in js?

Converts a value to another. E.g. Object to Boolean.

15

What does prototype do?

Allows objects to inherit features. Can be used to add features to objects.

16

null vs undefined

Null is DNE. Undefined means declared but not instantiated.

17

What are .bind, .call, and .apply used for?

Bind sets this to the first param in the function. Call is used to bind this to the scope of the passed object. Apply does the same but takes the arguments as an array.