JavaScript Basics Flashcards

1
Q

What is the principal use of arrays?

A

to store ordered lists of data

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

Describe the syntax (structure) of array-literals in JavaScript.

A

var array_name = [item1, item2, item3,…] ;

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

How can you access the last element of an array?

A

const fruits = [“Banana”, “Orange”, “Apple”, “Mango”];

let fruit = fruits[fruits.length - 1];

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

What data types can object properties hold?

A
booleans
strings
numbers
undefined
null
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe the syntax (structure) of object-literals in JavaScript.

A

var person = {firstName:”John”, lastName:”Doe”, age:50, eyeColor:”blue”};

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

What does the = (equals) operator do in JavaScript?

A

assignment operator: assigns the value to a variable

**does NOT mean “equal to”

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

Which keyword is used to declare a variable in JavaScript?

A

var
let
const

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

Which characters is a JavaScript variable allowed to begin with?

A

upper or lowercase letter
$ dollar sign
_ underscore

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

What are quotation marks used for in JavaScript?

A

text strings

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

What is the purpose of variables?

A

to store data values

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

What is the purpose of strings in JavaScript?

A

storing & manipulating text

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

What is the purpose of booleans in JavaScript?

A

logic to represent 1 of 2 values

true/false
on/off
yes/no

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

What is the purpose of numbers in JavaScript?

A

to represent and manipulate numbers

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

definition:

Null vs Undefined

A

null - intentional absence of any OBJECT value (put there by programmer as ex/ var nothing = null)

undefined - value never assigned (default value of variable ex/ var never)

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

What is the purpose of objects?

A

To group together set of variables and fxns to create a model of something from real world

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

What are the two ways to get or update the value of a property?

A
dot notation
bracket notation (substitutions)
17
Q

variables & memory location

objects & memory location

A

REFERENCE (objects) !== PRIMITIVES

var a = b
b can sometimes =/ a

obj a = obj b
they are the same because they are pointing to same memory address (and modifying that address)

18
Q

What data type do comparison expressions evaluate to?

A

booleans

19
Q

Give 6 examples of comparison operators.

A
===
!==
><
<=
>=
20
Q

What is the purpose of an if statement?

A

evaluates to a boolean

conditionally run code based on boolean value of expression

21
Q

Describe the syntax (structure) of an if statement.

A

if (condition) {
run code
}