JavaScript Flashcards
What is an object in JavaScript?
An object in JavaScript is a data type that represents a collection of data and methods.
What is an array in JavaScript?
An array in JavaScript is a data type that represents a list of values.
What is a constant in JavaScript?
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.
What is the scope of a let
variable?
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.
What is the difference between var
and let
in JavaScript?
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.
What is the difference between global scope and local scope?
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.
Can a global variable be accessed inside a function?
Yes, a global variable can be accessed inside a function.
Can a local variable be accessed outside of the function it is declared in?
No, a local variable cannot be accessed outside of the function it is declared in.