JavaScript Flashcards Preview

Web Development > JavaScript > Flashcards

Flashcards in JavaScript Deck (151)
Loading flashcards...
1

What is the purpose of variables?

The purpose of variables is to store value.

Why does this help? Variables can change & it exists for a longer time.(data permanence)

2

How do you declare a variable?

You declare a variable by using the var keyword and giving the variable a name.

3

How do you initialize (assign a value to) a variable?

You initialize (assign a value to) a variable with the = operator.

4

What characters are allowed in variable names?

Letters, numbers, dollar sign($), and underscore(_).

Note: dash(-) or period( . ) or question-mark(?) are not allowed & Numbers cannot go first.

5

What does it mean to say that variable names are "case sensitive"?

When it is said that variable names are "case sensitive" it means that capitalization matters.

Ex: String and string are not the same.

6

What is the purpose of a string?

The purpose of a string is to store text.

7

What is the purpose of a number?

The purpose of a number is to use it for math and calculations.

8

What is the purpose of a boolean?

The purpose of a boolean is to store if something is true or false. Booleans exist for decision making.

9

What does the = operator mean in JavaScript?

The = operator in JavaScript means that we are assigning a value to something.

10

How do you update the value of a variable?

You update the value of a variable by assigning a new value to the variable.

Note: You don't need the var keyword to assign a new value to an existing variable.

11

What is the difference between null and undefined?

Null: Primitive value that represents a reference that points, generally intentionally, to a nonexistent or invalid object or address. Null always need to be assigned to something.

Undefined: Primitive value automatically assigned to variables that have only been declared. Also assigned to formal arguments where there are no actual arguments.

12

What data-type is returned by an arithmetic operation?

A Number value is returned by an arithmetic operation.

13

What is string concatenation?

String concatenation is adding two or more strings to make a longer string.

14

What purpose(s) does the + plus operator serve in JavaScript?

The + plus operator adds numbers and concatenates strings in JavaScript.

15

What data type is returned by comparing two values (< , >, ===, etc)?

A Boolean value is returned by comparing two values (< , >, ===, etc).

16

What does the += "plus-equals" operator do?

A value on the right-side will be added to the variable, and the variable will then be updated to that new value.

17

What are objects used for?

Objects are used to group together a set of properties and methods to create a model of something.

18

What are object properties?

Object properties are variables glued to that object.

19

Describe object literal notation.

var hotel = {
name: 'Cosmopolitan',
rooms: 500,
booked: 300,
checkAvailability: function( ) {
return this.rooms - this.booked;
}
};

20

How do you remove a property from an object?

Removing a property from an object using the dot notation:
delete objectname.propertyname.

Removing a property from an object using the bracket notation:
delete objectname['propertyname'].

21

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

Updating/getting a property from an object using the dot notation: variablename.propertyname.

Updating/getting a property from an object using the bracket notation: variablename['propertyname'].

22

What are arrays used for?

Arrays are used to store a list of data with number indexes.

23

Describe array literal notation.

colors = ['white', 'blue', 'red']

24

How are arrays different from "plain" objects?

Arrays have orders to them unlike "plain" objects. Arrays will repair itself if a data is deleted.

25

What number represents the first index of an array?

0 represents the first index of an array.

26

What is the length property of an array?

The length property of an array tells us the number of data stored in an array.

27

How do you calculate the last index of an array?

We calculate the last index of an array by:

arrayname.length - 1

28

What is a function in JavaScript?

A function in JavaScript is giving a name to some amount of code so that it can be reused and also read easier.

29

Describe the parts of a function definition.

function functionName (parameters) {
return
}

30

Describe the parts of a function call.

functionName (arguments)

Note: Arguments don't have to be there.