IMS 322 - Chapters 1-3

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

array constructor

This uses the new keyword followed by Array(); The values are then specified in parentheses (not square brackets), and each value is separated by a comma. You can also use a method called item() to retrieve data from the array.

dot notation

To access a property or method of an object you use the name of the object, followed by a period, then the name of the property or method you want to access

function declaration

To create a function, you give it a name and then write the statements needed to achieve its task inside the curly braces.

a multi-line comment

To write a comment that stretches over more than one line, you use _______, starting with the /* characters and ending with the */ characters. Anything between these characters is not processed by the JavaScript interpreter.

undefined

Until you have assigned a value to a variable, programmers say the value is

In a single-line comment

anything that follows the two forward slash characters // on that line will not be processed by the JavaScript interpreter. Single-line comments are often used for short descriptions of what the code is doing.

Values in an array

are accessed as if they are in a numbered list. It is important to know that the numbering of this list starts at zero (not one).

floor()

ensures that the number is always rounded down to the nearest integer

An expression

evaluates into (results in) a single value

comments

explain what your code does. They help make your code easier to read and understand. This can help you and others who read your code.

two types of expressions

expressions that just assign a value to a variable; expressions that use two or more values to return a single value

Javascript must be run from within the .js file

false

Unlike HTML, javascript needs to be compiled to run

false

Web browsers can only represent Browser elements or Document level elements on the same page.

false

names[3]= "Lenny"; will place "Lenny" in 3rd array position

false

Arrange the sections of code into a properly formed iteration { parens and ; removed)

for int x=10, x>=0 x--

To define or declare a function called myFunction

function myFunction( );

numeric data type

handles numbers

Each property

has a name and a value

What are the 'three legs' of the html5 stool?

html, css, javascript

A method

is the same as a function, except methods are created inside (and are part of) an object.

wrapper object

it acts like a wrapper around any value that is a string

If a variable name is more than one word

it is usually written in camelCase. This means the first word is all lowercase and any subsequent words have their first letter capitalized.

Calling a method

makes a method call that invokes the called method

In an object, functions are known as _ of the object

methods

members

methods and properties of the document object

To call a function called myFunction

myFunction( );

JavaScript distinguishes between

numbers, strings, and true or false values known as Booleans.

Functions can take in information, called _ to perform tasks

parameters

grouping operators

parentheses there to ensure the interpreter treats this as an expression.

parseFloat

parses a string and returns a floating point number

parseInt:

parses a string and returns an integer.

In an object, variables are known as _ of the object

properties

There is just one string operator:

the + symbol. It is used to join the strings on either side of it.

event

the computer's way of sticking up its hand to say, "Hey, this just happened!"

separation of concerns

the design principle of breaking up web content using distinct languages and documents that overlap as little as possible

assignment operator

the equal sign

Which of the following assigns a number to a variable?

var quantity = 3 ;

when are booleans used

when the value can only be true/false OR when your code can take more than one path

originalNumber.toFixed(3)

will round the number stored in the variable originalNumber to three decimal places.

write():

writes HTML expressions or JavaScript code to a document.

To make web pages interactive,

you write code that uses the browser's model of the web page.

key

Like variables and named functions, properties and methods have a name and a value. In an object, that name is called

Which of the following are used in objects

Methods; Properties; Events

Object Oriented Programming Describes

Objects in terms of Properties and Methods; Properties describe how an object looks Methods describe what an object does (behavior)

assign a value to the variable.

Once you have created a variable, you can tell it what information you would like it to store for you. Programmers say that you

concatenation

Programmers call the process of joining together two or more strings to create one new string

Concatenation

Programmers call the process of joining together two or more strings to create one new string.

Each object can have its own:

Properties Events Methods

document object

The current web page loaded into each window is modelled using a document object.

presentation layer

The CSS enhances the HTML page with rules that state how the HTML content is presented (backgrounds, borders, box dimensions, colors, fonts, etc.).

Keywords

special words that tell the interpreter to do something.

modulus

% divides two values and returns the remainder

for

(var i = 0; i<=4; i++)

What is the symbol for multiplication in javascript?

*

increment

++ adds one to the current number

decrement

-- subtracts one from the current number

JS has five data types

1. String 2. Number 3. Boolean 4. Undefined 5. Null

Here are six rules you must always follow when giving a variable a name:

1. The name must begin with a letter, dollar sign ($), or an underscore (_). It must not start with a number. 2. The name can contain letters, numbers, dollar sign ($), or an underscore (_). 3. You cannot use keywords or reserved words. 4. All variables are case sensitive, so score and Score would be different variable names, but it is bad practice to create two variables that have the same name using different cases. 5. Use a name that describes the kind of information that the variable stores. 6. If your variable name is made up of more than one word, use a capital letter for the first letter of every word after the first word.

Here are three variations of how to declare variables and assign them values:

1. Variables are declared and values assigned in the same statement. 2. Three variables are declared on the same line, then values assigned to each. 3. Two variables are declared and assigned values on the same line. Then one is declared and assigned a value on the next line.

steps to performing a task

1. define the goal 2. design the script 3. code each step

how a browser sees a web page

1. receive a page as html code 2. create a model of the page and store it in memory 3. use a rendering engine to show the page on screen

anonymous function

A function with no name is called an

What is a built in object of JS?

Browser Object Model; Document Object Model; Global JavaScript Objects

What do properties describe?

Characteristics of objects, appearances

code block

Code that belongs together, often inside a branch or loop; surrounded by curly braces

statement

Each individual instruction or step (should end with a semicolon)

an index

Each item in an array is automatically given a number called _____. This can be used to access specific items in the array.

Syntax

How you put those words together to create instructions computers can follow

method

If a function is part of an object, it is called

property

If a variable is part of an object, it is called

global variable and global scope

If you create a variable outside of a function, then it can be used anywhere within the script.

function expression

If you put a function where the interpreter would expect to see an expression, then it is treated as an expression, and it is known as a

object

In computer programming, each physical thing in the world can be represented as an

named function

In order to call the function later in your code, you must give it a name,

identifier

In order to use the variable, you must give it a name

array literal

It is usually the preferred method for creating an array. The values are assigned to the array inside a pair of square brackets, and each value is separated by a comma. The values in the array do not need to be the same data type, so you can store a string, a number and a Boolean all in the same array.

how is a script like a recipe

Steamboat Natchez Jazz Dinner Cruise

built-in objects

The browser comes with a set of objects that act like a toolkit for creating interactive web pages.

what does a method do

The code for a method can contain lots of instructions that together represent one task.

Button onclick:

The onclick event occurs when the user clicks on an element.

alert box

The window object's alert() method is used to create a dialog box shown on top of the page.

Vocabulary

The words that computers understand

progressive enhancement.

These three layers form the basis of a popular approach to building web pages called

escaping the quotation characters

This is done by using a backwards slash (or "backslash") before any type of quote mark that appears within a string (as shown on the fourth line of this code sample). The backwards slash tells the interpreter that the following character is part of the string, rather than the end of it.

content layer

This is where the content of the page lives. The HTML gives the page structure and adds semantics.

behavior layer

This is where we can change how the page behaves, adding interactivity. We will aim to keep as much of our JavaScript as possible in separate files.

a local variable or function-level variable

When a variable is created inside a function using the var keyword, it can only be used in that function.

arguments

When you call a function that has parameters, you specify the values it should use in the parentheses that follow its name

return value

When you write a function and you expect it to provide you with an answer, the response is known as

scope of a variable

Where a variable is declared can have an effect upon whether the rest of the script can use it

object model

a group of objects, each of which represent related things from the real world. Together they form a model of something larger.

variable

a named place in memory that can store and change values

A real number is

a number that can contain a fractional part.

A floating point number is

a real number that uses decimals to represent a fraction. The term floating point refers to the decimal point.

Script

a series of instructions that a computer can follow to achieve a goal

An array

a special type of variable. It doesn't just store one value; it stores a list of values.

quantity

a value for the variable

Scientific notation is

a way of writing numbers that are too big or too small to be conveniently written in decimal form.

An integer

a whole number (not a fraction).

member operator

access the members of an object using a dot between the object name and the member you want to access

final parenthesis

after the closing curly brace of the code block tell the interpreter to call the function immediately

alert function

alert ("hello")

write() method

allows new content to be written into the page where the script element sits

var is

an example of what programmers call a keyword. The JavaScript interpreter knows that this keyword is used to create a variable.

Rather than using individual 'buckets' for many variables, we can use ____ (like grandma's pillbox)

arrays

Boolean data types

can have one of two values: true or false

How do you get the value yellow from this array: color=['pink,'yellow','green'];

color[1]

Functions

consist of a series of statements that have been grouped together because they perform a specific task.

string data type

consists of letters and other characters.

toFixed

converts a number into a string, keeping a specified number of decimals.

instances

create it using the constructor function

<th>

defines a header cell in an HTML table

<tr>

defines a row in an HTML table.

<td>

defines a standard cell in an HTML table.

Put the following pieces in order to display text in js

document write ( ... ); "Hello, world"

interpreted programming language

each line of code is translated one-by-one as the script is run.

parameters

each piece of information inside a method

document.getElementByName

returns a collection of all elements in the document with the specified name (the value of the name attribute)

random()

returns a random number from 0 (inclusive) up to but not including 1 (exclusive).

document.getElementById

returns the element that has the ID attribute with the specified value.

max()

returns the number with the highest value

min()

returns the number with the lowest value

pow()

returns the value of x to the power of y (xy).

operators

they allow programmers to create a single value from one or more values.

Being plain HTML

this layer should work on all kinds of devices, be accessible to all users, and load quite quickly on slow connections.

A web page is represented by the javascript document object

true

Arrays and Objects both hold sets of Values. The difference is how they are keyed/indexed

true

Arrays and Objects can contain each other

true

Functions allow you to group several statements together that represent one task

true

Just as a function can accept data as input, it can send info back to the line that called it.

true

Real information sent to a function that accepts parameters is called arguments

true

You can store more than one value in an array variable.

true

an " IF " block or statement is another name for a Conditional

true

methods

typically represent how people (or other things) interact with an object in the real world.

toPrecision(3)

uses the number in parentheses to indicate the total number of digits the number should have


Kaugnay na mga set ng pag-aaral

Ch 9 Cellular Respiration and Fermentation

View Set

Ch. 23: Legal Implications in Nursing Practice

View Set

Everything, Everything vocabulary

View Set

Financial Management Test 1 Whitledge MSState

View Set

Cognitive Psychology Exam 2 (Set: 1 of 5)

View Set