JavaScript Flashcards

1
Q

What is an object in JavaScript?

A

An object in JavaScript is a data type that represents a collection of data and methods.

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

What is an array in JavaScript?

A

An array in JavaScript is a data type that represents a list of values.

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

What is a constant in JavaScript?

A

A constant is a symbol that is assigned once when the program starts and never changes. Constants are useful to specify fixed values such as defining the constant PI to be 3.14159265, or COMPANY_NAME to hold the name of your company.

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

What is the scope of a let variable?

A

The scope of a let variable is the block in which it is declared.

This means that a let variable can only be accessed within the block where it is declared.

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

What is the difference between var and let in JavaScript?

A

var variables are global by default, while let variables are block scoped.

var variables can be re-assigned, while let variables cannot be re-assigned after they are initialized.

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

What is the difference between global scope and local scope?

A

Global scope refers to the ability of a variable to be accessed from anywhere in the code. Local scope refers to the ability of a variable to be accessed only from within the function it is declared in.

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

Can a global variable be accessed inside a function?

A

Yes, a global variable can be accessed inside a function.

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

Can a local variable be accessed outside of the function it is declared in?

A

No, a local variable cannot be accessed outside of the function it is declared in.

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