JS MUST KNOW Flashcards

1
Q

How many “Scopes” are there in JS?

A

In JavaScript, there can be following types of scopes:

Global Scope
Local Scope or Function Scope
Block Scope

`

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

What Do You Mean by “this“?

A

‘this’ is always a reference to an object

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

What is “Anonymous Function” in JS?

A

Anonymous Function is a function that does not have any name associated with it.

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

What Do You Know About BOM? (Browser Object Model)

A

The Browser Object Model (BOM) allows JavaScript to “talk to” the browser.

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

What is DOM?

A

When a web page is loaded, the browser creates a “Document Object Model” of the page.

The HTML DOM model is constructed as a tree of Objects.

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

How To Return a Character from a Specific Index?

A

charAt() string method

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

What are the Different Data Types in JS?

A

Primitive: String, Number, Boolean, Null, Undefined, Symbol, BigInt
Composite: Object and Array

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

What is “Prototype Property” in JS?

A

The prototype property allows you to add properties and methods to an object.

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

What is “Closure” in JS?

A

A closure gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created, at function creation time.

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

Asynchronous Programming and Its Importance

A

Accommodates for the lag between when a function is called to when the value of that function is returned.

allows user to go about their business in an application, while processes run in the background.

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

Why Debugging is Required in JS?

A

scenarios where the script does not show any error in the browser.

the output is not similar to what is expected.

best option to find out the error is by debugging. This can be done by either console.log() or by using the debugger keyword.

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

What is “Function Hoisting” in JS?

A

Function hoisting is a JavaScript mechanism where function declarations are moved to the top of their scope before code execution. (Excludes function expressions)

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

Naming Conventions for Variables in JS

A

Don’t use reserves key words ie. Boolean

Don’t start the variable name with a number.

Variables are case sensitive.

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

What is a “Callback” in JS?

A

A ‘callback’ function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.

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

What is “Global Scope”?

A

Global scope is the entire Javascript execution environment. Any variables assigned without an explicit scope automatically become global variables. The same is true for functions.

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

What is “Local Scope” in JS?

A

Variables declared within a JavaScript function are in local scope. They can only be accessed from within that function.

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

What will this “==” comparison operator return in JS?

A

It returns true if the operand on the left of it is (loosely) equal to the operand on the right of it.

18
Q

What will this “===” comparison operator return in JS?

A

It returns true if the operand on the left of it is (strictly) equal to the operand on the right of it.

19
Q

What is an “Object” in JS?

A

Objects are data structures that contain data. They can be a simple key/value pair, or they can be a complex system of nested key/value pairs representing a user and all of their posts, likes, friends, comments, personal data, etc.

20
Q

What is ‘Undefined(undefined)’ used for?

A

Used for unintentionally missing values.

21
Q

What is ‘Null (null)’ used for?

A

Used for intentionally missing values.

22
Q

What is ‘Booleans (true and false)’ used for?

A

Used for logical operations.

23
Q

What are ‘Numbers (-100, 3.14)’ used for?

A

Used for math calculations.

24
Q

What are ‘Strings (“hello”, “abracadabra”)’ used for?

A

Used for text.

25
Q

What are ‘Symbols (uncommon)’ used for?

A

Used to hide implementation details.

26
Q

What are ‘BigInts (uncommon and new)’ used for?

A

Used for math on big numbers.

27
Q

What is Object.is()?

A

Object.is() is a method that determines whether two values are the same value. Returns Boolean

28
Q

What is Object.assign()?

A

Object.assign() method is used to copy all enumerable own properties from one or more source objects to a target object.

29
Q

What is Object.entries()?

A

Object.entries() method returns an array of a given object’s key value pairs.

30
Q

What is Object.values()?

A

Object.values() method returns an array of a given object’s property values, in the same order as that provided by a for…in loop

31
Q

What is “The Window Object” is JS?

A

The window object is supported by all browsers. It represents the browser’s window.

32
Q

What automatically becomes members of “The Window Object”?

A

All global JavaScript objects, functions, and variables.

33
Q

What are the properties of the “The Window Object”?

A

Global variables.

34
Q

What are the methods of the “The Window Object”?

A

Global functions.

35
Q

What is Client-Side JavaScript (CSJS)?

A

Enables the enhancement and manipulation of web pages and client browsers.

36
Q

What is Server-Side JavaScript (SSJS)?

A

Enables back-end access to databases, file systems, and servers.

37
Q

What are the rules of declaring a “constant” in JS?

A

A constant cannot change value through assignment or be re-declared while the script is running.

const only prevents re-assignments but doesn’t prevent mutations.

38
Q

What is variable hoisting?

A

(var) declared variables are hoisted, you can refer to the variable anywhere in its scope, even if its declaration isn’t reached yet.

The value is always undefined, only declaration is hoisted, not its initialization.

39
Q

What is a “Template Literal” in JS?

A

A way to concatenate strings while allowing embedded expressions and improving readability.

40
Q

What is an “expression” in JS

A

A piece of code that produces a value.

41
Q

What does Object.create() method do?

A

Creates a new object, using an existing object as the prototype of the newly created object.

42
Q

What does the ‘new’ operator do?

A

Creates an instance of a constructor function, and binds the newly created object to the ‘this’ keyword for the duration of the function call.