Javascript

¡Supera tus tareas y exámenes ahora con Quizwiz!

Use the ____ statement to specify a block of code to be executed if the condition is false.

else

Use the ______ statement to specify a new condition if the first condition is false.

else if

The do/while loop is a variant of the while loop. This loop will

execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true.

if it returns _____, the loop will end.

false

The _______ statement lets you execute code, after try and catch, regardless of the result.

finally

Put the opening bracket at the end of the

first line.

The for loop has the following syntax:

for (statement 1; statement 2; statement 3) {}

A class is a type of _______, but instead of using the keyword function to initiate it, we use the keyword class, and the properties are assigned inside a constructor() method

function

Methods are stored in properties as

function definitions.

A JavaScript function is defined with the keyword

function, followed by a name, followed by parentheses ().

To add getters and setters in the class, use the ___ and ___ keywords.

get,set

Minimize the use of _____ variables.

global

Local variables must be declared with the var keyword or the let keyword, otherwise they will become

global variables.

You can use Math.max.apply to find the

highest number in an array:

Use the __ statement to specify a block of JavaScript code to be executed if a condition is true.

if

Often statement 3

increments the value of the initial variable.

However, after you have sorted an array, you can use the _____ to obtain the highest and lowest values.

index

You access an array element by referring to the

index number. (var name = cars[0];)

The code inside the function will execute when "something"

invokes (calls) the function: (When an event occurs (when a user clicks a button))

MAX_VALUE returns the

largest possible number in JavaScript.

The pop() method removes the ____ ________ from an array:

last element

Fixed values are called

literals.

for -

loops through a block of code a number of times

The while loop

loops through a block of code as long as a specified condition is true.

while -

loops through a block of code while a specified condition is true

for/in -

loops through the properties of an object

The JavaScript for/in statement

loops through the properties of an object:

for/of -

loops through the values of an iterable object

The JavaScript for/of statement

loops through the values of an iterable objects

You can use Math.min.apply to find the

lowest number in an array:

MIN_VALUE returns the

lowest possible number in JavaScript.

Statement 3 can do anything like ______ increment (i--), ______ increment (i = i + 15), or anything else.

negative, positive

The map() method creates a

new array by performing a function on each array element.

The filter() method creates a

new array with array elements that passes a test.

The push() method adds a ___ ________ to an array (at the end):

new element

NaN is a JavaScript reserved word indicating that a number is

not a legal number.

valueOf() returns a

number as a number.

The toString() method returns a

number as a string.

You access an object method with the following syntax:

objectName.methodName()

Use ___ space before the opening bracket.

one

An array is a special variable, which can hold more than

one value at a time.

The numbers (in an arithmetic operation) are called

operands.

The operation (to be performed between the two operands) is defined by an

operator.

A variable declared _______ a function, becomes GLOBAL.

outside

_____ contains the lowest value

points[0]

____________contains the highest value

points[points.length-1]

toExponential() returns a

string, with a number rounded and written using exponential notation.

toPrecision() returns a

string, with a number written with a specified length:

toFixed() returns a

string, with the number written with a specified number of decimals:

Use the _______ statement to select one of many code blocks to be executed.

switch

In programming, text values are called

text strings.

The constructor property returns

the constructor function for all JavaScript variables.

The indexOf() method returns

the index of (the position of) the first occurrence of a specified text in a string:

The findIndex() method returns

the index of the first array element that passes a test function.

The length property returns

the length of a string

The find() method returns

the value of the first array element that passes a test function.

Normally you will use statement 1 to initialize the _______ used in the loop (i = 0).

variable

Variable values are called

variables.

JSON is often used when data is sent from a server to a

web page.

Local variables can only be accessed from

within the function.

Number() can be used to convert

JavaScript variables to numbers

Variables declared within a JavaScript function, become ______ to the function.

LOCAL

_____ are handy, if you want to run the same code over and over again, each time with a different value.

Loops (Often this is the case when working with arrays)

_____ and ______ can be used to find the lowest or highest value in a list of arguments:

Math.min() , Math.max()

he global method ________ can also convert booleans to numbers.

Number()

The most important rules for writing fixed values are:

Numbers are written with or without decimals:

parseFloat()

Parses its argument and returns a floating point number

parseInt()

Parses its argument and returns an integer

Number()

Returns a number, converted from its argument.

The search() method searches a string for a

specified value and returns the position of the match:

In a programming language, variables are used to

store data values.

The JavaScript method toString() converts an array to a

string of (comma separated) array values.

A JavaScript function is executed when

"something" invokes it (calls it).

Statement 3 is executed

(every time) after the code block has been executed.

Statement 1 is executed

(one time) before the execution of the code block.

Always use __ spaces for indentation of code blocks:

2

JavaScript Numbers are Always _____ Floating Point

64-bit

Here are some examples of HTML events:

An HTML web page has finished loading, An HTML input field was changed, An HTML button was clicked

You can use the _______ function to find out if an expression (or a variable) is true:

Boolean()

If you assign a value to a variable that has not been declared, it will automatically become a ______ variable.

GLOBAL

The JavaScript syntax defines two types of values:

Fixed values and variable values.

The global method ______ can convert numbers to strings.

String()

There are 3 JavaScript methods that can be used to convert variables to numbers:

The Number() method, The parseInt() method, The parseFloat() method

An expression is

a combination of values, variables, and operators, which computes to a value. (For example, 5 * 10 evaluates to 50:)

The slice() method slices out

a piece of an array into a new array.

Methods are

actions that can be performed on objects.

The splice() method can be used to

add new items to an array:

The every() method check if

all array values pass a test.

do/while -

also loops through a block of code while a specified condition is true

The indexOf() method searches

an array for an element value and returns its position.

The reduce() method runs a function on each

array element to produce (reduce it to) a single value.

The reduceRight() method runs a function on each

array element to produce (reduce it to) a single value. (The reduceRight() works from right-to-left in the array. See also reduce().)

With JavaScript, the full array can be accessed by referring to the

array name: Ex. var cars = ["Saab", "Volvo", "BMW"]; document.getElementById("demo").innerHTML = cars;

A JavaScript function is a

block of code designed to perform a particular task.

The _____ statement "jumps out" of a loop.

break

When JavaScript reaches a _____ keyword, it breaks out of the switch block.

break

The forEach() method

calls a function (a callback function) once for each array element.

All JavaScript identifiers are

case sensitive.

The _____ statement lets you handle the error.

catch

If your browser supports debugging, you can use __________ to display JavaScript values in the debugger window:

console.log()

Variables defined with _____ behave like let variables, except they cannot be reassigned:

const

The _________ statement "jumps over" one iteration in the loop.

continue

The concat() method

creates a new array by merging (concatenating) existing arrays:

for/of lets you loop over

data structures that are iterable such as Arrays, Strings, Maps, NodeLists, and more.

Always end your switch statements with a

default. Even if you think there is no need for it.

The catch statement allows you to

define a block of code to be executed, if an error occurs in the try block.

The try statement allows you to

define a block of code to be tested for errors while it is being executed.

Statement 2

defines the condition for executing the code block.

An HTML event can be something the browser

does, or something a user does.

Strings are written inside

double or single quotes.

JavaScript numbers are always stored as ______ _______ floating point numbers, following the international IEEE 754 standard.

double precision

Numbers are written without

quotes.

The shift() method

removes the first array element and "shifts" all other elements to a lower index.

When JavaScript reaches a ______ statement, the function will stop executing.

return

parseFloat() parses a string and

returns a number. Spaces are allowed. Only the first number is returned:

Math.random()

returns a random number between 0 (inclusive), and 1 (exclusive):

parseInt() parses a string and

returns a whole number. Spaces are allowed. Only the first number is returned:

Math.abs(x)

returns the absolute (positive) value of x:

Math.sqrt(x)

returns the square root of x:

Math.floor(x)

returns the value of x rounded down to its nearest integer:

Math.round(x)

returns the value of x rounded to its nearest integer:

Math.ceil(x)

returns the value of x rounded up to its nearest integer:

Math.pow(x, y)

returns the value of x to the power of y:

The reverse() method

reverses the elements in an array. (You can use it to sort an array in descending order:)

Always end a simple statement with a

semicolon.

Do not end a complex statement with a

semicolon.

A regular expression is a

sequence of characters that forms a search pattern.

Arrow functions allow us to write ______ function syntax:

shorter (hello = () => { return "Hello World!";}

The some() method check if

some array values pass a test.

The sort() method

sorts an array alphabetically:

The ______ statement lets you create custom errors.

throw

If statement 2 returns _____, the loop will start over again,

true

The ___ statement lets you test a block of code for errors.

try

You can use the _______ operator to find the data type of a JavaScript variable.

typeof

Objects are variables too. But objects can contain many _______

values. (Fiat, 500, white) to a variable named car

The ___ keyword tells the browser to create variables:

var


Conjuntos de estudio relacionados

Quill: Furthermore, In Addition, & Moreover

View Set

Steps to vitamin D synthesis and it's effects

View Set

SP #3: Marine Provinces and Ocean Floor Features

View Set