Grammar and types Flashcards

1
Q

What are the three kinds of variable declarations

A

var - Declares a variable, optionally initializing it to a value

let - Declares a block-scoped, local variable, optionally initializing it to a value

const - Declares a block-scoped, read-only named constant

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

What is a variable

A

Variables are symbolic names for values in your application

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

What are the rules for variable names

A

A variable must start with a letter, underscore (_) or dollar ($) sign

Subsequent characters can also be digits (0-9)

It is case sensitive so letters include both upper (A-Z) and lower (a-z) cases

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

What is variable scope

A

Variable scope can be either global or local

Global variable scope is when a variable is declared outside of any function and is available to any code within the current document

Local variable scope is when a variable is declared inside of a function and is only accessible within the function

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

What is variable hoisting

A

Hoisting refers to the lifting of variables to the top of the function or statement calling them

Variables that are declared after they are called are returned as “undefined” rather than throwing an exception

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

Describe function hoisting

A

A function declaration will run successfully without error as they are hoisted

A function expression on the other hand will return a TypeError indicating is not a function

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

List the primitive (or simple) data types

A
  1. Boolean - returns either true or false
  2. null - a variable with no value
  3. undefined - a variable that has been declared but no value assigned yet
  4. Number - an integer or floating point number
  5. String - a sequence of characters that represent a text value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

List the complex data type

A

Object - this includes arrays and functions as both are considered types of objects

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