Massive Javascript Set

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

match

Fill in the ??? var text= "Maggie, 1, 2, 3 Darrin"; ==> text.m????(/[a-zA-Z]+/g) ==> ["Maggie", "Darrin"];

PI is what?

PI approx (3.14159)

How can you avoid having to use an onload function?

Place the code at the bottom of the script at the end of the DOM.

pow(x,y)

Returns the value of x to the power of y

%=

Shortcut assignment operator for x=x%y operation

what does the n{x} quantifier do?

matches any string that contains a sequences of x n's x="100, 1000 or 10000" y=/\d{4}/g document.write(x.match(y))--> 1000,1000

what deos the ?!n quantifier do?

matches any string that is not follwed by specific string n x="hello world" y=/hello(?!world)/g document.write(x.match(y))-->

+=

shortcut assignment operator for x=x+y operation

status line

the bottom portion of the screen that shows loading progress

!false

true

Parameters

values that function computes on

Is JavaScript case sensitive?

Yes

What is the string escape sequence to insert a vertical tab in JavaScript?

\v

how do you create variables in javascript?

by using the var statement or by assigning a value to a new variable like this:x=3 var x=3;

Write "Hello" on the page (only for test).

document.write("Hello");

Access an HTML element wiht id="element".

document.getElementById("element");

How do you change the style/class on any element?

document.getElementById("myText").style.fontSize = "20";

Change the text of the paragraph with the id="par".

document.getElementById("par").innerHTML="New text";

How do you write text to the current element of the DOM?

document.write("Text Here"); //Remains on current line

If an array with name as "names" contain three elements, then how will you print the third element of this array?

document.write(names[2]);

How do you write a line to the current element of the DOM?

document.writeln("Text Here"); //Advances to new line after text

For radio buttons, how do you get the current checked status of the control?

document.getElementById("radioButtonId").checked;

For radio buttons, how do you get the text value of the control?

document.getElementById("radioButtonId").value;

How do you alter the value of the text element in a span tag?

document.getElementById("spanId").firstChild.nodeValue = "New Value";

Changing an HTML Attribute

document.getElementById("xxx").xxx="xxx";

get by id

document.getElementById('anId');

In JavaScript, an array is a special type of object. Therefore typeof[1,2,3,4] returns __

object

What are the valid characters for an identifier in JavaScript?

Letters, Numbers, Underscores, and Dollar Signs

open()

Opens a new browser window

+

Operator for addition

--

Operator for decrement

/

Operator for division

++

Operator for increment

Sometimes you will see all the JavaScript functions in the ____ section.

<head>

In the <script> tag, how is the Type attribute used?

<script type="text/javascript"> //Used to denote the type of script being used. Always this for JavaScript

what is a javascript statement?

A JavaScript statement is a command to a browser. The purpose of the command is to tell the browser what to do.

Index

A variable that is usually assigned the initial value of zero. This variable is used to access objects contained in the array.

unshift

Complete this statement to add 'Superman' to *start* of array. arMovies.???????('Superman');

IF statements

Comprised of an IF keyword, a condition and a pair of curly braces { }. If the answer to the condition is yes, the code inside the curly braces will run.

Example of a conditional statement where "i" is equal to 5

if(i==5)

what happens if you redeclare a javascript variable?

it retains its original value

$.post()

jQuery.post( url [, data ] [, success(data, textStatus, jqXHR) ] [, dataType ] )

concat() method does what?

joins 2 or more arrays array.concat(array2)

<

less than

getTime()

Returns the number of milliseconds since midnight Jan 1, 1970

min(x,y,z,...,n)

Returns the number with the lowest value

parent

Returns the parent window of the current window

pageXOffset

Returns the pixels the current document has been scrolled (horizontally) from the upper left corner of the window

port

Returns the port number the server uses for a URL

indexOf()

Returns the position of the first found occurrence of a specified value in a string

lastIndexOf()

Returns the position of the last found occurrence of a specified value in a string

protocol

Returns the protocol of a URL

search

Returns the query portion of a URL

getSeconds()

Returns the seconds (from 0-59)

getUTCSeconds()

Returns the seconds, according to universal time (from 0-59)

sin(x)

Returns the sine of x (x is in radians)

MIN_VALUE

Returns the smallest number possible in JavaScript

SQRT1_2

Returns the square root of 1/2 (approx. 0.707)

SQRT2

Returns the square root of 2 (approx. 1.414)

sqrt(x)

Returns the square root of x

tan(x)

Returns the tangent of an angle

ceil(x)

Returns x, rounded upwards to the nearest integer

Two reasons for packaging algorithms into functions

Reuse: the building blocks of future programming; complexity management: keeps our sanity while solving problems.

reverse()

Reverses the order of the elements in an array

what is the advantage of using "get" and "set" property definitions?

Since JavaScript automatically creates objects, if you misspell a property name, a new property can be created. Creating the set and get property methods prevents this issue

setUTCMonth()

Sets the month of a date object, according to universal time

split()

Splits a string into an array of substrings

How do you create a multi-line comment in JavaScript?

Start with a forward slash and asterisk, and then end with an asterisk and forward slash. "/*" "*/"

What happens when % is placed between two numbers?

The computer will divide the first number by the second, and then return the remainder of that division.

tables

Tables are commonly represented as arrays of arrays. var table = [ ["data1", "data2"], ["data3, "data4"] ];

3 things required for animation

Using a timer to initiate animation events, prefetching the frames of the animation, redrawing a web page image.

JavaScript

make websites respond to user interaction ; build apps and games ; access information on the Internet ; organize and present data

pass-by-value

makes a copy

alert box syntax?

alert("message");

alerts

alert("you are right)

What String object method is used to get the character at a specified index position?

charAt(position);

isNaN

checks if a value is NaN

!=

checks if the values aren't equal

Form validation

checks information the user entered into a form.

Number

converts a string to a number, but may return NaN

counter = counter + 1 (shorthand)

counter += 1

counter = counter + 1 (super shorthand)

counter++

prompt()

dialog box that asks for user input

confirm()

dialog box with two options, OK and Cancel

window.alert

displays dialog box

loop

disturbance in the sequence of statements, it may cause the program to repeat some statements multiple times.

Modulus operation

divides by 2 and gives the remainder %

For textboxes, how do you set focus on the control?

document.getElementById("TextBoxId").focus;

For checkboxes, how do you get the text value of the control?

document.getElementById("checkboxId").value;

How do you change the content of an HTML element identified with id = "demo"?

document.getElementById("demo").innerHTML = "Hello JavaScript";

For a text area, how do you get the current value of the control?

document.getElementById("textAreaId").value;

How do you access a page element by id?

document.getElementById(id);

Run-Time Error An

error that is produced when incorrect terms are used in the Javascript code. An incorrect command or out of sequence format will throw this type of error.

\B meta character does what?

find a match that is not at the beginning of a word (or returns null) x="hello world" y=/\Borld/g document.write(x.match(y))--> orld

quantities (4)

type: numbers

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

typeof

!

unary operator "not" !true = false !false = true

The value of a variable with no value is ___

undefined

Variable declared without a value will have the value ___

undefined

console.log("")

what is printed out on the screen

c

what value do methods push() and unshift() return? a) 0 on successful completion, -1 if error b) the number of new items added c) the total number of items in the array, after the method finishes

what does the n{x,y} quantifier do?

matches any string that contains a sequence of X to Y n's [x and y must be #'s] x="100, 1000 or 10000" y=/\d{4,5}/g document.write(x.match(y))--> 1000,10000

what does the n+ quantifier do?

matches any string that contains at one n x="hello world" y=/w+/g document.write(x.match(y))--> hello,world

what does the ?=n quantifier do?

matches any string that is followed by a specific string of n x="hello world" y=/hello(?=world)/g document.write(x.match(y))--> hello

what does the ^n quantifier do?

matches any string with n at the beginning x="hello world" y=/^he/g document.write(x.match(y))--> he

3 parts of a function

name, parameters, definition

A variable is a ____ and a literal is a ____

name, value

Name properties and methods that are common for form elements

name, value, form, type

string variable

represent text, always enclosed in quotes cannot be divided multiplied, or subtracted + concatenates (adds) two strings together

"I'm the man".length > 10

represents a boolean (a true of false response from computer) the computer would return with true

reverse

reverses elements in array

data validation

checks the input for certain specified values

Length Method

checks to see how many cells in a given array. .length

player=new Array("Larry","Moe","Curley","Shep","Chuck");

condensed array

console.log

console.log("print me");

call object values

console.log(sally.name); = Sally

typeof

creates a string naming the type of the value you give it ex: typeof 4.5 = number operates on only one value

/

division

The Do While Loop

do { xxx; ++x; } while (xxx);

parent object?

document

How do you submit a form using JavaScript?

document.forms[0].submit();

For checkboxes, how do you set the current checked status of the control?

document.getElementById("CheckboxId").checked = true; //Could also be false

For textboxes, How do you set the control to be disabled?

document.getElementById("TextBoxId").disabled = true; //Could also be false to enable it

For textboxes, How do you get the current value?

document.getElementById("TextBoxId").value;

Changing HTML Content

document.getElementById("xxx").innerHTML="xxx";

Changing HTML Style

document.getElementById("xxx").style.xxx="xxx";

What are two ways to get the number of elements in a form named myForm?

document.myForm.length and document.myForm.elements.length

Client side validation

done by javascript. Occurs on user's computer in their browser before the form is even submitted.

element

each indexed item of the base named seqeunce

else action?

executes if the condition is false.

what's the difference between an expression and a statement?

expressions return a value, for example (6 * 5) returns 30. but statements may or may not return a value.

\s meta character does what?

finds a whitespace chracters x="hello world " y=/\s/g document.write(x.match(y))--> , ,

.bind()

fn.bind(context, arguments) will return a new function that is permanently bound to the context

.call() arguments?

fn.call(context, arguments)

for loop

for(i=0; i < 10; i++){ console.log(i); }

inheritance

function MainClass(params){ function code; } SubClass.prototype = new MainClass();

function syntax and purpose?

function functionName(var1,var2,..,var99) { some code } functions allows scripts to be executed when called.

how do you define a function?

function functionname(var1,var2,...,varX){some code}

JavaScript function

function myFunction() { }

return statement syntax?

function product(a,b) { return a*b; } alert(product(4,3)) <-- will alert 12 return function gives a value back based on function variables.

function functionname() { Some code to be done }

function syntax

JavaScript Function Syntax

function xxx() { xxx; }

NaN

not a number

!==

not equal to

data types

numbers strings booleans arrays objects

3 types if data in javascript

numbers, strings, Booleans

3 types of data in javascript

numbers, strings, Booleans

What are the simple types of JavaScript?

numbers, strings, booleans, null and undefined

Family

parentNode, previousSibling, nextSibling, firstChild and lastChild.. But this will get messed up for text nodes

what does the max() method do?

returns the number with the highest value Math.max(x,y,z) document.write(Math.max(10,5,-1))-->10

valueOf() method does what?

returns the primitive value of an array array.valueOf()

give an individual object a method

snoopy.bark = function(){ console.log("Woof"); }

methods

specialized functions

the last index in a string is?

string.length-1

syntax

structure used for writing code

object constructor

var me = new Object(); me.name = "Sara"; me.age = 21;

object literal

var me = { name: "Sara", age: 21 }

Amy

var myName = "Amy"; console.log(myName);

3

var myName = "Amy"; console.log(myName.length);

function

var myName = function(){ console.log("Sara"); }

return

var myName = function(){ return "Sara"; }

How do you code a while statement in JavaScript?

while (condition) {}

how do you create an object?

with curly braces

how do you insert Javascript into a web page?

with the script tag:<script type="text/javascript">document.write("Hello World!");</script>

can javascript detect a browser type?

yes and version.

syntax for line breaks in an alert box?

'/n' + " here"

string

'Hi, Ivy!' is what data type

What is the syntax of a conditional operator?

(Condition_Expression) ? Value_If_True : Value_If_False;

What is the syntax for linking a css file name app?

<link rel="stylesheet" type="text/css" href='app.css' />

assignment symbol

=

close()

Closes the current window

converting values: false

0 and an empty string == false

buttons

Icons you can click on to navigate around on the computer or a web page.

What is the 'for in' statement for?

Looping over all of the property names in an object

confirm

alerts an ok/cancel question with the given argument

definition

algorithm written in programming language

||

binary operator means "or" true if either of the values given is true lowest precedence

method in constructor notation

bob.setAge = function(newAge){ bob.age = newAge; };

true or false (24 > 3)

boolean

confirm()

prompt()

An object is a container of what?

properties

||

Or

Logical not

!

what is the difference between InnerHtml and OuterHtml

OuterHtml returns the surrounding tags

interpretation

term programmers use to describe the line by line conversion process that occurs at the time it is run.

tst

test

What operations would lead to a NaN?

0/0 Infinity/Infinity Take squareroot of negative number Use arithmetic operators with non-numeric operands that can't be converted to numbers

hexadecimal

0x

equal to

===

greater than or equal to comparison operator

>=

Name the date and time functions

- setDate(), setMonth(); setFullYear() - setHours, setMinutes(), setSeconds(), setMilliseconds()

add class using $

$.addClass()

full stop

.

What is this? var myArray = [[[]]];

A 3D array

How many scripts can you place in an HTML document?

As many as needed

function

Block of code that wil be executed when someone "calls it"

toPrecision(x)

Formats a number to x length

insertbefore

Node.insertBefore()

define the term 'statement'

a command to the browser

return

gets values back to the calling code

==

is equal to

What does "%" return?

the remainder only

Comparison Operators "is not equal to"

!=

not equal to

!==

$.hasClass()

...

Math object methods

...

modulo

14%3 = 2

modulo

16%5 === 1 because 16/5=3 with 1 left over

Control Specification

3 operations in the parentheses of the for loop control the number of times the loop iterates

What is JavaScript?

A scripting language used most often for client-side web development

array

A variable that can take on multiple values

objectName.methodName()

Access object Methods

Syntax Error

An error produced when a script's format or shape is incorrect, a misspelling is found, or text is not recognized. Also thrown when you have opened a command, but then do not close it.

Objects

Are functions.

When does the binding of 'this' to the object happen?

At invocation time

Where does the hadOwnProperty method not look?

At the prototype chain

Document Object Model (DOM)

Browser records all of the information about a webpage in this data structure

How are objects passed around?

By reference

How can a 'TypeError' exception be guarded against?

By testing for the property using &&

If a function literal has a name, what can it do?

Call itself recursively.

setTimeout()

Calls a function or evaluates an expression after a specified number of milliseconds

setInterval()

Calls a function or evaluates an expression at specified intervals (in milliseconds)

document.body.bgColor="red";

Change the backgroud color of the page using DOM.

What is the chrome shortcut to bring up the console? What about toggling the console?

Cmd + option + j esc toggles the console.

What are three things functions in JavaScript are used for?

Code reuse, information hiding, and composition

constructor notation

Constructor notation is where we make use of the keywords new Object(). We then use dot notation to add property and values to the object.

<html>

Contains all the HTML in a page

<body>

Contains all the content of a page

What does the "get" method for the customerName property in the CustomerBooking reference type look like?

CustomerBooking.prototype.getCustomerName = function() { return this.customerName; }

what function can you use to write the current date?

Date()

How to create arrays in JavaScript?

Declare array: var names = new Array(); names[0] = "Amy"; Another way: var names = new Array("Amy", "Alex");

getYear()

Deprecated. Use the getFullYear() method instead

isFinite()

Determines whether a value is a finite, legal number

isNaN()

Determines whether a value is an illegal number

alert(arrayVar[2]);

Display the third value from an array.

blink()

Displays a blinking string

italics()

Displays a string in italic

big()

Displays a string using a big font

fixed()

Displays a string using a fixed-pitch font

Token

Either a variable name or a literal constant that is followed by a relational operator. A JavaScript condition will always consist of two of these.

encodeURI()

Encodes a URI

encodeURIComponent()

Encodes a URI component

===

Equal to

=

Equals assignment operator (x=y assigns y to x)

fromCharCode() method does what?

converts unicode values into characters [does not use strings] document.write(string.fromCharCode(72))--> H

_____ cannot contain <script> tags.

External

slice()

Extracts a part of a string and returns a new string

slice() method does what?

extracts a part of a string and returns the extracted part in a new string(-1 if null) e.x. string.slice(begin,end) x="hello" document.write(x.slice(0,3))---> hell

substring() does what?

extracts characters from a string between two specified #'s and returns it as a new string. [start at 0] e.x. string.substring(from,to) x="hello world" document.write(x.substring(0,4))--->hello

toFixed(x)

Formats a number with x numbers of digits after the decimal point

Closure

Function defined inside a function.

Arguments

Function name and input values

Math.max

Function that gives the largest number

Math.min

Function that gives the smallest number

Where can functions be returned from?

Functions

Constructors

Functions that are used to initialize objects.

What are higher-order functions.

Functions that work on other functions. Refer to chapter 6 of eloquent JavaScriptcript for the details on this. Essentially you write what you want to do instead of how you want to do it. Its a higher level of thinking and code production that results in less messy loops and cleaner code. Here is a brief example: function forEach(array, action) { for (var i = 0; i < array.length; i++) action(array[i]); } forEach(["Wampeter", "Foma", "Granfalloon"], print); In this example you pass the action you want to perform as the second parameter to the function.

$.offset()

Get the current coordinates of the first element, or set the coordinates of every element, in the set of matched elements, relative to the document.

var curDate=new Date();

Get the today date and time and put it inside a variable.

reverse

Given the following declaration, write the method that will flip the array, last-to-first. var ar1 = ['a','b','c']; ar1.???????(?);

join("|")

Given the following, what method should you attach to array a1 to make s2 == s1? Provide the full method call, including all arguments (if any); var s1 = "a|b|c"; var a1 = s1.split("|"); s2 = a1.???

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

Global

for (i=0;i<cars.length;i++) { document.write(cars[i] + "<br>"); }

Go through array for length

>

Greater than

>=

Greater than or equal to

typeof

How to tell what type (object, string, etc) a variable is? Answer: Use the ?????? function.

isNaN

How to test if a variable holds a number or something else? is???

HTML

Hypertext Mark up Language

Difference between property and attribute

I dont know

What is the syntax of the Legacy IE Event model?

IE 8 and below dont use addEventListener. They use attachEvent. It accepts similar parameters. The event name has to be prefixed with 'on' though. Also, it doesn't take a third argument. Information about the event can be passed as an argument to the function or it can be accessed by the global object event. It is a property of the window object.

How to add JavaScript onto a web page?

If your script code is very short and only for single page, then following ways are the best: a) You can place <script type="text/javascript"> tag inside the <head> element. b) If your script code is very large, then you can make a JavaScript file and add its path in the following way: <head> <title>Page Title</title> <script type="text/javascript" src="myjavascript.js"></script> </head>

!=

Is not equal to

<=

Less than or equal to

what does NaN stand for?

Not a Number, for example 4/0 is NaN

JavaScript types

Number, String, Boolean, Function, Object, Null, Undefined

parseInt()

Parses a string and returns an integer

LN2

Returns the natural logarithm of 2 (approx. 0.693)

length

Returns the number of frames (including iframes) in a window

properties of methods defined?

properties - are values associated with an object i.e. length methods - are actions (functions) that can be performed on objects ie toUpperCase [an uppercase method]

charAt() method does?

returns the character at the specified index e.x. string.charAt(index) x="hello world" document.write(x.charAt(0))-->h

indexOf() method does?

returns the position of the first found occurrence of a specified value in a string e.x. string.indexOf(searchstring,start) x="hello world" document.write(x.indexOf("world",0))-->7

_____ is the set of variables you have access to.

Scope

scrollBy()

Scrolls the content by the specified number of pixels

scrollTo()

Scrolls the content to the specified coordinates

indexOf()

Search the array for an element and returns it's position

Name 7 JavaScript data types

String, Number, Boolean, Array, Object, Null, Undefined

"yourname".length

To discover the length of your name

Decrement

To subtract one member from a value.

When will the code inside an IF code's curly braces run?

When the answer to the IF condition is yes

How can you split a string into an array at positions of the matches against a RegExp pattern?

text.split(pattern)

when i access the "Math" object, (for example Math.max(1, 2)), what scope is "Math" found in?

the Global scope

if()

a loop that executes once

Alert

a method used within the hypertext link or the window object to create a dialogue box. The box contains text denoted in the alert parentheses and an OK button that must be pressed before the user can continue.

expression

a piece of code that produces a value values that are written directly are expressions (ex: 22 or "psychoanalysis") binary operator applied to two values or a unary applied to one is an expression

function

a piece of program wrapped in a value

var

a place to save values

compiler

a program that decodes instructions written in a higher order language and produces an assembly language program

Web browser

a program used to view HTML documents

Every function object is created with what property and what is its value?

a prototype property; its value is an object with a 'constructor' property whose value is the function

If you put quotes around a numeric value, it will be treated as ___

a text string

objectName.propertyName

accessing property of an object

Comparison operator?

allow you to compare things within webpage

= or a=b *= or a *= b /= or a /= b %= or a %= b += or a += b -= or a -= b

assignment operators (also known as combination operators)

what is a conditional operator?

assigns a value to a variable based on some condition.

LOG10E

base-10 logarithm of E approx (0.434)

x.innerHTML="Hello Javascript";

change element

toUpperCase()

change item to upper case

to cancel a timer

clear Timeout(timer ID);

binary code

code using a string of 8 binary digits to represent characters, read by computers

environment

collection of variables and their values that exist at a given time

what is String concatenation

combining two strings together, like "a" + "b" becomes "ab"

In HTML, JavaScript statements are ____

command lines executed by the web browser

//

comment

What String object method is used to concatenate multiple strings?

concat(var1, var2, varN);

prompt

displays a dialog box where user can input value

For Loop

for (var xxx=xxx; xxx; ++x) { xxx; }

+

for addition

>=

greater than or equal to

child object?

object after parent object

Name some of the events for a web page

onload, onunload, links[0].onclick

Function ____ are the names listed in the function definition

parameters

command that creates pop up box for user input

prompt(" ");

slice() method does what?

selects a part of an array and returns an array [starts from 0, original not changed] array.slice(begin,length) x=["1","2","3"] document.write(x.slice(0,2))-->1,2

How do you end a JavaScript statement?

semi colon

strings

sequences of characters; letters, numbers, spaces

initialization for a loop

sets the iteration variables value for the first iteration of the loop

method?

something that an object can do.

handle

special code used by computers to identify which timer is being used

what does the global property do?

specified if the "g" modifier is set /regexp/g

what does the ignoreCase property do?

specified if the "i" modifier is set /regexp/i

what does the lastIndex property do?

specified the index at which to start the next match [specified character position after last match] x="string string string" y=/regexp/gi while(y.text(x)==true) { document.write("i found the index at: " + y.lastIndex) } firstmatch index number, second match index number

split() method does what?

splits a string into an array of substring and returns the new array e.x. string.split(separator,limit) x="hello world" document.write(x.split(" ",1))---> hello

How do you determine the length of a string?

string.length

how to enter data type strings?

surround them with quotes, "Are your sure?"

shift

take off first element of array

pop

take off the last element of array

parseFloat()

takes float out of a string, string must start with a number

isNaN()

tests if NaN

What property do you look at to determine the number of items in an array of the number of forms on a page?

the length property. document.forms.length or <arrayName>[arrayName.length] remember that the arrays starts at 0 so subtract 1 from the value of the array.length to determine access the desired array object

console.log(myState);

this command will print the string that is stored in the variable myState

the purpose of the boolean object?

to convert a non-boolean value to a boolean value (true or false) value.

what is meant by decalring a variable?

to create a variable

in what ways can you use comments in JavaScript?

to document your code (which you should do!) to debug. comment, instead of delete, a line to see if that is the problem

when do you use the If...else statement?

to execute some code if a condition is true and another code if the condition is not true.

what is the purpose of a function

to keep code from executing until needed.

what is the purpose of statement blocks?

to make the sequence of statements execute together

toString

to string

What Date object method is used to return a string containing the date?

toDateString();

What Number object method is used to return a number in exponential format with the specified number of decimal places?

toExponential(digits);

null == undefined

true

the boolean has a default value of?

true

what does this return? isNaN('a')

true

boolean

true is what data type

Booleans can only have two values

true or false

Boolean values

true or false, letter sequence, values, used implicitly

how to enter data type numbers?

use numbers only without quotes

How can you create an object that represent dates and times?

use the Date() constructor. var now = new Date() //current date and time

when do you use the if statement?

use this statement to execute some code only if a specified condition is true

var

used to create a new variable

\n meta chracter does what?

used to find a newline character (only useful in alert text) x="hello \n world" y=/\n/g document.write(x.search(y))--> 5

Variable Syntax

var xxx ="xxx";

JavaScript Arrays (literal)

var xxx=["xxx"];

when must the return statement be used?

when using a function that needs to return a value

The While Loop

while (xxx) { xxx; ++x; }

while loop

while(i < 10) { console.log(i); i++; }

The while loop (a loop executed when a specific condition is met) syntax?

while(variable<=endvalue) { code to be executed }

console.log()

will take whatever is inside the parentheses and log it to the console below your code

How do you make the browser load a new page using JavaScript?

window.location = "New Web Address Here";

How do you view the current web address using JavaScript?

window.location();

how to call a function?

with an event or another function

key words

words that cannot be used as variable names for example: for, var, while

"reserved for use" words

words that cannot be used as variables

document.write("<p>My First Javascript</p>");

write into the HTML document output (Over rides all content in HTML)

To access first cell in an array?

x[0]

what defines start and end of function text?

{ }

Logical Operator "or"

||

Logical or

||

length

"string".length

What two additional parameters do every function receive?

"this" and "arguments"

What happens when a method is invoked?

"this" is bound to that object

substring

"wonderful day".substring(3,7); = derf

$ events

$.click() $.dblclick() $.blur() $.unbind() $.unload() $.submit() $.mouseover() $.mouseenter() $.keypress() $.keydown()

find descendants $

$.find() Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.

$ remove attribute

$.removeAttr() $.removeClass()

$ forms

$.serialize() Encode a set of form elements as a string for submission. $.serializeArray() Encode a set of form elements as an array of names and values. $.val()

Get/set text of element $

$.text()

$ wrap an element

$.wrap() $.wrapAll() $.wrapInner() $.unWrap()

modulo, gives remainder

%

Modulus

% divides two numbers and gives back remainder

"And" operator

&&

Logical Operator "and"

&&

Logical and

&&

Which two filters are most useful in avoiding unwanted values returned in the 'for in' statement?

'typeof' and the 'hasOwnProperty' method

What is necessary at the end of every function name?

( )

What is the syntax for the ternary operator

( if condition ) ? true : false; (direction === "true" ) ? nextSlide : previousSlide;

and

(1 === 1) && (1 !=3); true

or

(1 === 1) || (1 ===3); true

multiply

*

What are the events supported by textarea?

- onkeydown - onkeypress - onkeyup - onchange

false,deleted

// In the followign top-level code, what gets printed on the console log? Reason: Explicitly declared global variables, unlike implictly declared ones, can't be d?. --------------------- var x = "howdy"; y = "yo"; var rc = delete x; console.log (rc);

test

// fill in the ??? var p=/[0-9]/; ==>p.t???("Da0rrin") == > true

what does this return? "".length

0

7 values that make boolean false

0 -0 null " " false undefined NaN <-- not a number

numeric

0.75 is what data type

Name 3 ways to define a color in HTML

1) Hex 2) RGB 3) Name (ie red)

function,block,function,hoisted,undefined

1) Variables in JavaScript have f? scope, not b? scope. 2) B/c of f? scope, local variables are "h?" to the top of the function they're defined in. This means that if a local variable has the same name as a global one, it hides the global one--even before the statement that declares/initializes it appears. Let's illustrate. What does the first "console" statement display? ========================== var glob = 13; function func () { console.log(glob); var glob = 26; console.log (glob); }

What is the process of adding text to an element.

1) You have to create the element that will hold the text. 2) Next you have to create and store a text node, with createTextNode( 'your text' ); 3) Lastly append it to the element created in step one.

global,this,window

1) Your program's global variables, constructor methods like Date, and constants like Infinity are properties of what object? 2) Finish the following top-level statment (i.e. not in any function) to refer to this object: var glob = ????; 3) For client-size JavaScript, name another object that refers to the global object

new,conversion,false

1) a) and 1b) When you use Number(), Object(), Boolean(), or String() without the ??? operator, these methods become c????????? methods. 2) Example; String (?????) ==> "false";

What is the difference when you use an = sign when assigning to a variable or to an object?

1) the value of the variable will be changed 2) the object will remain but the pointer to the object will be changed

Where does JavaScript often appear in an HTML document?

<head>

What is an example of a character set that can be added so that the browser does not throw an error in the debugger?

<meta charset="utf-8">

How do you set a value to an html element using JavaScript?

<p id="ResultsP"></p> <script type="text/javascript"> document.getElementById('ResultsP').innerHTML = 'Hello World!'; </script>

In the <script> tag, how is the Defer attribute used?

<script defer="defer"> //Used to ensure the code doesn't run until the rest of the page has been loaded

What is the syntax to reference an external JavaScript file?

<script type = "text/javascript" src="filename.js"></script>

What is the syntax to add an external JS file?

<script type='text/javascript' language='javascript' src='Path to your external js file'/>

Comparison Operators "is equal to"

==

What is the difference between == and ===?

== checks equality only === checks for equality as well as type

Comparison Operators "is exactly equal to (value and type)"

===

greater than comparison operator

>

What is an event handler?

A function that is called with a certain event occurs. Examples of these include button.onclick and window.onload.

Compiler

A highly specialized piece of software that takes a programming language understandable by humans and converts it into a language that computers can understand.

Function

A piece of JavaScript code that can be called upon to perform certain tasks. These are written by the programmer and can contain any number of JavaScript statements, including calls to other functions or methods.

If Statement

A piece of code that allows a decision based on whether or not a condition is met. It always allows only two options; either the condition is met or not. An example would be when determining to see if a certain check box is checked.

ReferenceError

A word Java script doesn't know

What is an event and an event handler?

An event is something that happens in the browser. An event handler is a function that executes and "handles" the event by performing a sub routine.

onLine

Boolean, returns true if the browser is on line, otherwise false.

Often you will see scripts at the ____ of the <body> section of a web page. What does this do?

Bottom, Reduces display time. (Improves page load because HTML loading is not blocked by scripts loading)

Document Object Model (DOM)

Browser records all of the information about a web page in this data structure

myDiv.innerHTML = "My new content";

Change the content of an HTML element.

clearInterval()

Clears a timer set with setInterval()

Assignment

Command to change the value of a variable

operators

Compare two tokens (Ex. ==, !=, <, >, etc.)

what are comparison operators?

Comparison operators are used in logical statements to determine equality or difference between variables or values

compile()

Compiles a regular expression

shift

Complete the following code to remove the value 'Track1' from the following array: arPlaylist = [ 'Track1','Track2', 'Track3']: var t1 = arPlaylist.?????();

pop

Complete the following code to remove the value 'Track3' from the following array: arPlaylist = [ 'Track1','Track2', 'Track3']: var t3 = arPlaylist.???();

search

Complete the method call. var t = "howdy"; [console] >> t.s?????(/ow/) => 1 ------------------

what are conditional statements

Conditional statements are used to perform different actions based on different conditions

<head>

Contains most of the unseen information

What is contextual selector?

Contextual selector addresses specific occurrence of an element. It is a string of individual selectors separated by white space (search pattern), where only the last element in the pattern is addressed providing it matches the specified context.

fromCharCode()

Converts Unicode values to characters

toUTCString()

Converts a Date object to a string, according to universal time

toLocaleString()

Converts a Date object to a string, using locale conventions

toExponential(x)

Converts a number into an exponential notation

toLowerCase()

Converts a string to lowercase letters

toUpperCase()

Converts a string to uppercase letters

toString()

Converts an object to a string

Number()

Converts an object's value to a number

anchor()

Creates an anchor

What does the "set" method for the customerName property in the CustomerBooking reference type look like?

CustomerBooking.prototype.setCustomerName = function(customerName) { this.customerName = customerName; }

decodeURI()

Decodes a URI

setYear()

Deprecated. Use the setFullYear() method instead

toGMTString()

Deprecated. Use the toUTCString() method instead

what does this do? prompt()

Displays a dialog box that prompts the visitor for input

confirm()

Displays a dialog box with a message and an OK and a Cancel button

link()

Displays a string as a hyperlink

sub()

Displays a string as subscript text

small()

Displays a string using a small font

fontcolor()

Displays a string using a specified color

fontsize()

Displays a string using a specified size

strike()

Displays a string with a strikethrough

/

Division arithmetic operator

substr()

Extracts the characters from a string, beginning at a specified start position, and through the specified number of character

substring()

Extracts the characters from a string, between two specified indices

Output of: var object1 = { same: 'same' }; var object2 = { same: 'same' }; console.log(object1 === object2);

False, because JavaScript doesn't care that they're identical and of the same object test. When comparing complex objects, they're equal only when they reference the same object. Two variables containing identical objects are not equal to each other since they don't actually point at the same object.

What do the blur() and focus() methods do? Do they fire the submit event handler?

Focus - any keypress will be passed directly to the element - can be selected by mouse click to tab key or programmatically with the focus() method Blur - remove a form element from being the focus - typically focus shifts to the page containing the form These functions do not fire the submit event handler

//

For a Comment which is ignore by the computer

How do the patterns of invocation differ?

In how the parameter 'this' is initialised

What MAY removing a property from an object do?

It may allow a property from the prototype linkage to shine through

<

Less than

Typing

Loose.

What Math object method is used to return a given number raised to a given power?

Math.pow(number, power);

What Math object method is used to return a random number?

Math.random() //Returns a value >= 0.0 but <1.0

math functions

Math.random(); = between 0 and 1 Math.floor(1.6); = 1 Math.ceil(1.4); = 2 Math.round(1.5); = 2 Math.pow(2, 3); = 8

What Math object method is used to return a given number that has been rounded to the closes integer value?

Math.round(number);

What Math object method is used to return the square root of a given number?

Math.sqrt(number);

moveBy()

Moves a window relative to its current position

moveTo()

Moves a window to the specified position

frame

Movies, cartoons, etc. animate by the rapid display of many still pictures known as

how are multi line comments started

Multi line comments start with /* and end with */.

Java allows enclosed within /* and */,

Multiple Line Comments

Block Comment

Multiple lines of text can be commented out using the commands /* at the beginning of the paragraph and the command */ at the end. Everything in between will be commented out.

*

Multiplication arithmetic operator

lastIndexOf

Name the hinted at method call (sans args) to return the index of the last "e" in the following string; var s = "howdy there"; s.l???I????O?('e');

indexOf

Name the hinted at method call (sans args) to return the index of the last "e" in the following string; var s = "there"; s.i??????('e',3);

Does deleting a property from an object affect any of the objects in the prototype linkage?

No

Quotes

No difference between single and double quotes.

%

Operator for modulus

hasOwnProperty

Own properties are distinct from prototype properties, which are discussed in Chapter 4.

parse()

Parses a date string and returns the number of milliseconds since midnight of January 1, 1970

What are pseudo classes?

Pseudo classes allow you to identify HTML elements on characteristics (as opposed to their name or attributes). The classes are specified using a colon to separate the element name and pseudo class. A good example is the :link and :visited pseudo classes for the HTML A element. Another good example is first-child, which finds an element's first child element. The following CSS makes all visited links red and green, the actual link text becomes yellow when the mouse pointer is positioned over it, and the text of the first element of a paragraph is bold. a:link {font-color: red;} a:visited {font-color: green;} a:hover {font-color: yellow;} p.first-child {font-weight: bold;}

reload()

Reloads the current document

blur()

Removes focus from the current window

random()

Returns a random number between 0 and 1

opener

Returns a reference to the window that created the window

frames

Returns an array of all the frames (including iframes) in the current window

platform

Returns for which platform the browser is compiled

document

Returns the Document object for the window (See Document object)

history

Returns the History object for the window (See History object)

location

Returns the Location object for the window (See Location object)

navigator

Returns the Navigator object for the window (See Navigator object)

screen

Returns the Screen object for the window (See Screen object)

charCodeAt()

Returns the Unicode of the character at the specified index

hash

Returns the anchor portion of a URL

acos(x)

Returns the arccosine of x, in radians

asin(x)

Returns the arcsine of x, in radians

atan2(y,x)

Returns the arctangent of the quotient of its arguments

atan(x)

Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians

LOG10E

Returns the base-10 logarithm of E (approx. 0.434)

LOG2E

Returns the base-2 logarithm of E (approx. 1.442)

colorDepth

Returns the bit depth of the color palette for displaying images

charAt()

Returns the character at the specified index

appCodeName

Returns the code name of the browser

pixelDepth

Returns the color resolution (in bits per pixel) of the screen

cos(x)

Returns the cosine of x (x is in radians)

self

Returns the current window

toJSON()

Returns the date as a string, formated as a JSON date

toISOString()

Returns the date as a string, using the ISO standard

toLocaleDateString()

Returns the date portion of a Date object as a string, using locale conventions

getUTCHours()

Returns the hour, according to universal time (from 0-23)

getUTCMonth()

Returns the month, according to universal time (from 0-11)

UTC()

Returns the number of milliseconds in a date string since midnight of January 1, 1970, according to universal time

max(x,y,z,...,n)

Returns the number with the highest value

pageYOffset

Returns the pixels the current document has been scrolled (vertically) from the upper left corner of the window

getTimezoneOffset()

Returns the time difference between UTC time and local time, in minutes

toLocaleTimeString()

Returns the time portion of a Date object as a string, using locale conventions

top

Returns the topmost browser window

height

Returns the total height of the screen

width

Returns the total width of the screen

userAgent

Returns the user-agent header sent by the browser to the server

appVersion

Returns the version information of the browser

availWidth

Returns the width of the screen (excluding the Windows Taskbar)

screenLeft

Returns the x coordinate of the window relative to the screen

screenX

Returns the x coordinate of the window relative to the screen

screenTop

Returns the y coordinate of the window relative to the screen

screenY

Returns the y coordinate of the window relative to the screen

getFullYear()

Returns the year (four digits)

floor(x)

Returns x, rounded downwards to the nearest integer

var roundedVar = Math.round(2.3);

Round a float value to the closer integer and put the result inside a variable.

round(x)

Rounds x to the nearest integer

lastIndexOf()

Search the array for an element, starting at the end, and returns it's position

setTime()

Sets a date and time by adding or subtracting a specified number of milliseconds to/from midnight January 1, 1970

defaultStatus

Sets or returns the default text in the statusbar of a window

innerHeight

Sets or returns the inner height of a window's content area

innerWidth

Sets or returns the inner width of a window's content area

name

Sets or returns the name of a window

length

Sets or returns the number of elements in an object

outerHeight

Sets or returns the outer height of a window, including toolbars/scrollbars

outerWidth

Sets or returns the outer width of a window, including toolbars/scrollbars

setDate()

Sets the day of the month of a date object

setUTCDate()

Sets the day of the month of a date object, according to universal time

setHours()

Sets the hour of a date object

setUTCHours()

Sets the hour of a date object, according to universal time

setMilliseconds()

Sets the milliseconds of a date object

setMonth()

Sets the month of a date object

setSeconds()

Sets the seconds of a date object

status

Sets the text in the statusbar of a window

setFullYear()

Sets the year (four digits) of a date object

setUTCFullYear()

Sets the year of a date object, according to universal time (four digits)

*=

Shortcut assignment operator for x=x*y operation

-=

Shortcut assignment operator for x=x-y operation

/=

Shortcut assignment operator for x=x/y operation

What is global abatement?

Significantly reducing the use of global variables in JavaScript

What is the difference between a checkbox and radio buttons?

Similar properties, methods and events - Radio buttons are basically a group of checkboxes where only one can be checked at a time

How are simples types and object types different? How are simple types not "object-like"?

Simple types are immutable.

javaEnabled()

Specifies whether or not the browser has Java enabled

<b>

Tag (obsolete) for bold text

<i>

Tag (obsolete) for italic text

<div>

Tag for a box

<br>

Tag for a line break (enter)

<a>

Tag for a link

<ol>

Tag for a list with a certain order

<p>

Tag for a paragraph

<td>

Tag for a single table cell

<tr>

Tag for a table row

<li>

Tag for an element in a list

<img>

Tag for an image

<ul>

Tag for an unordered list

<strong>

Tag for bold text

<meta>

Tag for extra information

<script>

Tag for inserting Javacripts

<table>

Tag for inserting table

<em>

Tag for italic text

<title>

Tag for the page's title

<span>

Tag to edit inline elements

<style>

Tag to embed CSS into HTML

objects,wrapper,read

The alert method reports "undefined" for the following fragment b/c strings, numbers and boolean values are not o??????. But, to enable calling properties and methods like str1.length, JavaScript creates temporary w?????? objects. var t = "some string"; t.abc = 3; alert (t.abc); - Properties of strings, numbers and booleans are r???-only.

Status line

The area of the screen that displays various messages at the bottom of the browser's window that can be accessed from within a JavaScript program.

condition

The argument that must be evaluated

Provide an example of where the onfocus and onblur events are useful?

The onfocus and onblur are events where code can be written, the onblur event is a good place to write validation code.

What is the difference between var obj = { }; and var obj = new myObject( );

The second uses a constructor function. It does some setup behind the seen setting the constructor property as well as defining a prototype for the object. Method one simply instantiates the object from the default Object object.

What is the stack and how does it work?

The stack is the context of the executing script. While the function is running the main program must remember the point where it jumped into the function and what was going on there. This includes things like the variables available and their state. This is the stack. Each time a new function is called from the main routine a new snapshot of the context has to be taken and added on top of the stack. This requires memory. When the stack grows too large the browser dies and you get an error in the console.

for in vs object.keys(object)

There is a difference between the enumerable properties returned in a f or-in loop and the ones returned by Object.keys() . The for-in loop also enumerates prototype properties, while Object.keys() returns only own (instance) properties. The differ-

External JS File

This is a file with nothing but Javascript written in it and saved with a .js extension. Using this allows you to set functions that all pages in a web site can use because all pages can be given access to this file.

keywords

This is a group of reserved terms in a language that are used for function names, variable uses or coding processes; these words cannot be used to name variables that you create. Some keywords are: var, function, if, for, Array, Date, document, return.

getMinutes()

This is a method of the Date object. It returns a numeric representation of the current minute (00-59).

getSeconds()

This is a method of the Date object. It returns a numeric representation of the current second (00-59).

getDate()

This is a method of the Date object. It returns a numeric representation of the date (1-31).

getHours()

This is a method of the Date object. It returns a numeric representation of the hour (0 -midnight- 23).

getYear()

This is a method of the Date object. It returns a two-digit numeric representation of the year (0-99).

listener

This is a piece of code that can detect computer events and trigger an action in response. In HTML some attributes of tags are considered such. Examples are a button recognizing onmouseover and onclick. They are programmed to only work when the type of event they are set up for happens to the thing they are attached to.

variable

This is a reference to a stored value; the stored value can be changed. The reference can be used to manipulate the value stored in the variable by having a new value assigned to it.

statement

This is a series of instructions that a computer can follow one-by-one.

String

This is a series of letters in a sequence; basically just text. It needs to be used inside quotes for it to be seen as a String by a program.

array

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

event

This is any action by the user that afffects the computer and that the computer recognizes. These can include keystrokes, mouse clicks, files loading or attaching a USB device. Javascript can recognize keystrokes and multiple mouse actions like clicking. It can also recognize internal things like the clock changing time.

scope

This is the area of code that a variable can be seen in. It is derived from where the variable is first declared. Sometimes it is limited to within a function, sometimes it is limited to inside a single web page or sometimes it can extend throughout an entire website if the variable is passed from page to page.

Javascript

This is the scripting language of web pages. By using it to access and manipulate web page parts it can make pages interactive and dynamic.

DOM-Document Object Model

This is the tree list of items on a web page. This is what allows Javascript to find and manipulate parts of a web page. All items on a web page branch out from the main root item of 'document'.

Object

This is the ultimate datatype in a programming language. It can hold multiple properties and can have functions as a part of it. It is a coded items in Javascript, not a simple data form like numbers and letters. They are what are made when a prototype is called and it creates one of itself in the program. An Array is an example of one of these.

syntax

This is the way a language is written so it can be processed and run as a program. An example is when the language requires the programmer to name a new variable with a keyword preceding it. Some languages use a dot to combine things together like objects and their methods or to get access to properties inside an object. An example of this would be document.getElementById().

colors[2] = 'beige';

This is used to change the third array in the var of color to beige in single quotes

var

This is used to create a new variable

src

This is used to link the javascript file to the html page

data

This is what is put after the = to say what the variable is

Iterative Development

This is when a developer produces a version of a project and then makes revisions and improvements to create a better version of the project. When this happens over and over to get to the final product it produces an increasingly advanced version.

assignment

This is when a value is associated with a named variable. The equal (=) sign is the assignment operator. Example: shoesize = 14;

declare

This is when a variable is first named in code. A variable can simply be named using the keyword "var" and then later a value can be given to the variable.

string

This operator combines two strings

assignment

This operator is used to assign a value to a variable

logical

This operator is used to combine expressions and return true or false

comparison

This operator is used to compare two values and return true of false

arithmetic

This operator is used to perform basic math

What is one way to minimise the use of global variables?

To create a single global variable

true

To duplicate an array or object, you have to do it one element or property at a time (like in a 'for' loop). True or false?

when do you use the switch statement?

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

How can you create privacy in JavaScript and what are some examples of its use?

Using a closure you can create private areas in your code. Usages might be a global namespace for your code, private data members for sensitive info and such.

How do you assign the value from a prompt to a non-string variable?

Using a parse. Example : var intVar = parseInt(prompt("Text Here"));

slice(-2,-1)

Using only negative indices, write the slice() call that returns ['b'] from the array ['a','b','c']

How do you save data in javascript?

Using the var command: Example var myAge = 23 console.log(myAge) This will produce the number 23. **variable name is case sensitive**

parameters or arguments

Values given to functions

Local Function

Variables declared in a function that can only be used within that function

What are two advantages to using 'for' instead of 'for in'?

We can get the properties we want in the correct order, as well as avoiding looking at the prototype chain

What is grouping in CSS?

When more than one selector shares the same declaration, they may be grouped together via a comma-separated list; this allows you to reduce the size of the CSS (every bit and byte is important) and makes it more readable. The following snippet applies the same background to the first three heading elements.

text nodes

When passing HTML to jQuery(), please also note that text nodes are not treated as DOM elements. With the exception of a few methods (such as .content()), they are generally otherwise ignored or removed. E.g:

Infinite Loop

When the condition is never false, and therefore the browser keeps looping

When are a function's parameters initialised?

When the function is invoked

$.css

When using .css() as a setter, jQuery modifies the element's style property. For example, $( "#mydiv" ).css( "color", "green" ) is equivalent to document.getElementById( "mydiv" ).style.color = "green". Setting the value of a style property to an empty string — e.g. $( "#mydiv" ).css( "color", "" ) — removes that property from an element if it has already been directly applied, whether in the HTML style attribute, through jQuery's .css() method, or through direct DOM manipulation of the style property. It does not, however, remove a style that has been applied with a CSS rule in a stylesheet or <style> element

b

Where is the constant MIN_VALUE stored? a) the Math object b) the Number object c) none of the above

a

Which shows the correct argument list for the splice() array method? a) start idx, num of elements to remove, new elements b) start idx, end idx, new elements

immutable

Why didn't s1 change it's value? because in JavaScript, strings are i????????. var s1 = "howdy"; s1.toUpperCase(); ==> s1 == "howdy";

How do statements end in JavaScript?

With a semicolon ";"

dot notation

With an object obj that has a property myProp, we can retrieve this value by using obj.myProp.

bracket notation

With an object obj that has a property myProp, we can retrieve this value by using obj["myProp"].

How do you denote a string in JavaScript

With either single or double quotes surrounding the data

How are function objects created?

With function literals

private and public class methods or variables

Within a class, a variable or method is made public with the 'this.' prefix. A variable or method is made private by simply declaring 'var methodOrVariable...'.

Keywords

Words recognized by the programming language as a part of its language as part of its language and cannot be used as variable names. Examples: IF, ELSE, or RETURN

WFI

World famous iteration : ( j=1; j<3; j++)

What is a common technique used to sandbox your code's scope and state making it local instead of global?

Wrapping it all in a self invoking anonymous function or name spacing it in a global object.

write

Write is a method that acts upon the object document to post text to a page.

document.write(person.firstname + " is " + person.age + " years old.");

Write out content mixed together

splice(1,1,'Excalibur')

Write the array method call that will replace 'Return of the Jedi' with 'Excalibur' in this array: var arMovies = ['Star Wars', 'Return of the Jedi', 'The Empire Strikes Back'];

How do you attach something to the DOM?

You can call appendChild on the document objects target. Ex: document.body.appendChild(el);

How many scripts can You put in a page?

You can put any scripts in a page

How do you access an elements parent?

You can use element.parentNode;

how do you define a multi-dimensional array?

You define an array, then within the first element of an array, you define a new array. var personnel = new Array(); personnel[0] = new Array();

what does the compile() method do?

[edits source] the compile method is used to compile and recompile a regexp y=/regexp/ y.compile(regexp,modifier)

Escape symbol for javascript

\

What is the string escape sequence to start a new line in JavaScript?

\n

variable?

a "basket" into which you can put information

what does the following code mean? <input type="button" onclick="displayDate()" value="Display date" />

a button is created. when the button is clicked, the function displayDate() is executed. the value of the button is "Display date"

array

a collection of similar objects that can be accessed via the use of a variable

what is a cookie?

a cookie is a variable that is stored on a users computer.

loop

a disturbance in the sequence of statements that may cause the program to repeat some statements multiple times

Function?

a group of javascript lines that are put together for a particular purpose and given a name

what is a javascript block?

a group of statements grouped by curly brackets

define the term 'block'

a group of statements surrounded by curly brackets ( '{' and '}' ). blocks execute together

Event Handler

a javascript command that is "built-in" to the HTML code. It does not need to be set aside as a script itself. The command are placed with the HTML to create interaction between the user and your page.

what is javascript?

a sequence of statements to be executed by the browser

collection?

a set of all the particular child objects within that page`

function

a set of statements that performs a task or calculates a value; reusable piece of code

document.write();

a way to write something to the HTML page. document.write("Hello world!"); // writes "Hello world!" var x = "Hello world"; // assigns "Hello world!" to x document.write(x); // writes "Hello world!"

\x,\u

a) Represent any Latin-1 character by preceding its hex number with what escape sequence? b) Represent any Unicode character by preceding its hex number with what escape sequence? (Separate the two answers with a comma)

i++

add 1 to i

unshift

add an element at the beginning of array

push

add to the end of the array

$.append()

add to this element different from appendTo()

push() method does what?

adds new elements to an array [alters original] array.push(ele1,ele2,..,ele99) x=["1","2","3"] x.push("4") document.write(x)-->1,2,3,4

unshift() method does what?

adds new elements to the beginning of an array and returns new length array.unshift(ele1,ele2,...,ele99) x=["1","2","3"] document.write(x.unshift("4"))-->4

push

adds new value to the end of an existing array

Dot Operator

aids in navigation between elements

prompt

alert box with an open-ended question (type in answer)

How do you display an alert?

alert("Alert Text Here");

Definition

algorithm written in a programming language

toString,valueOf,toString

all objects inherit two conversion methods: ???? and ???? (give longer first) You can use ???? to convert dates, regex's, arrays and funcs to string representations that look much like the object you converted from.

collection?

all of one type of child object on the page.

onUnload

an Event Handler that is placed inside the BODY command of the HTML document and either calls for a function or contains the command to stop a function from running when the user unloads, or leaves, the page.

onBlur

an Event Handler that occurs when a select, text, or textarea form item is acted upon and then moved off of by the user. In other words, the user loses focus on the item.

onChange

an Event Handler that occurs when the text in a select, text, or textarea form item is altered by the user. Usually this command is used to check what the user has entered for errors.

onClick

an Event Handler that occurs when the user clicks on an object such as a link.

onMouseOver

an Event Handler used within the hypertext link that reacts when the user passes a mouse pointer over the link text.

psuedo-random numbers

an algorithm produces a sequence of numbers that passes the statistical test for randomness

What do you call the software structure used to intercept events?

an event handler or listener.

Location

an object denoting a specific URL. It is most commonly found in this format: parent.location='index.html'

Window

an object denoting the browser screen.

Document

an object name that refers specifically to the HTML document that contains the Javascript.

what is a regular expression?

an object that describes a pattern of characters

Date

an object that you name in order to be able to grab date and time methods. The format for naming the object is:

what is an array?

an object used to store multiple values in a single variable.

how many scripts can you have in a document?

an unlimited number.

numbers

are always floats

regexp metacharacters

are characters with a special meaning

Numbers

are quantities

Strings

are sequences of characters, like the letters a-z, spaces, and even numbers.

Function ______ are the real values received by the function when it is invoked

arguments

operators

arithmetic symbols such as *,+,/,-

push

array.push(text["Sara"]); = ["Sara"]

What four things in JavaScript are objects?

arrays, functions, regular expressions, and objects

You can break up a code line within a text string with a ___

backslash

How would you check if a variable is null/undefined?

bar === null typeof bar === "undefined"

Data Types

boolean, number, string, null, undefined, and various object types

Confirm

boxes that can be used on websites to make a user agree.

block

braces create blocks blocks combine multiple statements into a single statement in the world outside the block

sort

by default it sorts by strings, need to add comparator to change it

how can you make JavaScript execute when you want it?

by using a function. the code will execute after a specified event has occurred

array

can store many different types of values, index/subscript always starts at 0, data structures consisting of related data items

Variables defined inside a function are local variables. They _____be accessed outside of that function.

cannot

variable names

cannot include spaces can include digits cannot start with a digit

how do you write variables?

capitalize the 2nd word, and so forth, after the first word with no spaces. example: youAreCool

What is capturing & bubbling?

capturing says the event take an outside in approach, starting at the html root level and then propagates down to the event target, being the actual item clicked. Bubbling is the reverse. It takes an inside out approach and starts at its current event target and bubbles all the way up to the top. This can be problematic bc if an event is capturing and propagating down it would fire every click event that is registered on elements it hits on the way to the target. Another problem is IE 8 and below dont support capturing, they only support bubbling. T

x.style.color="#ff0000";

change style

nameName = (new) data

changed variable code

toLowerCase()

changes item to lower case

side effects

changes that occur due to a statement changing the internal state of the program

charAt()

character at, returns character at the index

if statements

checks the condition it is given, and executes the statement after it based on the condition only does it once, so the statement is executed zero or one time

If/then statements?

checks to see if condition is true. Example: If condition is true, does a. If not true, does else, or b. If no else, and condition not true, do nothing.

is used to test a conditional statement and then return one value if the conditional statement is true or another value if the conditional statement is false.

conditional operator

variablename=(condition)?value1:value2; votable=(age<18)?"Too Young":"Old enough";

conditional operator

that perform different actions depending on a condition. different code gets executed for different conditions.

conditional statements (also called conditional expressions or conditional constructs)

confirm("")

confirm pop-up

has own property

console.log(myName.hasOwnProperty('name')); if it has property will print true.

typeof

console.log(typeof aBool); = boolean

Instance

contained in parentheses immediately following the command. The Instance contains information about what an object is to do or how a method is to be carried out.

statement allows you to skip the rest of the lines in a loop until the end of the loop, but not exit the loop. say you wanted to add the even numbers from 1 to 9.

continue

if-else

control statement; checks a condition; if true, first block of code is executed, if false, second block of code is executed

toString() method does what?

converts an array to a string, returns the result x=["1","2","3"] document.write(x.toString())-->1,2,3

counter = counter * 2 (shorthand)

counter *= 1

counter ++, counter --

counter = counter +1 counter = counter -1

+=, -=, *= 2

counter = counter +1 counter = counter -1 counter = counter*2

.length

counts number of characters in a string

var cars = new Array(); cars[0] = "Saab"; cars[1] = "Volvo"; cars[2] = "BMW";

create arrary

prompt("...","...")

creates a dialog box that allows the user to input information

alert()

creates a dialog window in the browser

confirm()

creates a dialog window in the browser that gives you an OK(returning true) or Cancel(returning false).

while()

creates a loop

scope of a name

defines how "far" from a declaration it can be used

what does abs() method do?

determines the absolute value of x Math.abs(x) document.write(Math.abs(-7))-->7

numbers

do not use quotes around these when used in computations

while / for loop

do things more than once

loop is similar to the while statement, except the condition testing occurs at the end of the loop (making loop a posttest loop). In a loop, the loop code is always executed at least once.

do...while

Creating New HTML Elements

document.createElement("x");

Creating New Text Node

document.createTextNode("x");

How do you code a button.onclick event handler?

document.getElementById("ButtonId").onclick = functionName;

For checkboxes, how do you get the current checked status of the control?

document.getElementById("checkboxId").checked;

Changes the content of an HTML element identified with id="demo" setting it to "Hello world".

document.getElementById("demo").innerHTML = "Hello world";

Change the text of <p id="demo">

document.getElementById("demo").innerHTML = "New text";

Show the date in an element with the id attribute "demo".

document.getElementById("demo").innerHTML = Date();

How would you change the fontsize of an HTML element called "demo:

document.getElementById("demo").style.fontsize = "25px";

For lists, how do you get the value or the currently selected item?

document.getElementById("listId").value;

For radio buttons, how do you set the current checked status of the control?

document.getElementById("radioButtonId").checked = true; //Could also be false

How do you access the text element in a <span> tag?

document.getElementById("spanId").firstChild;

For a text area, how do you set the current value of the control?

document.getElementById("textAreaId").value = "Text Value";

What is an alternative way to select items in the DOM and how well is it supported?

document.querySelector( ) and document.querySelectorAll( ) and they accept css selectors. Works on IE8 (~March 2009) and up as well as FF 3.5 (~OCT 2010) and up and safari 3.2( ~ Pre 2007 ) and up.

is check box checked?

elem.checked if ( $( elem ).prop( "checked" ) ) NOT $( elem ).attr( "checked" ) for check box,

get element attributes

element.getAttribute(attributename) $().attr()

innerhtml

element.innerHTML

How do you find out what kind of tag a node is?

element.tagName;

else { console.log("") }

else statement format

serialize()

encode a set of form elements as a string for submission. $( "form" ).on( "submit", function( event ) { event.preventDefault(); console.log( $( this ).serialize() ); });

statement

ends with a ; simplest statement is an expression ending with ;

===

equal to

===

equal, used in comparisons

JavaScript code is written to be executed when a _____ occurs, like when the user clicks a button.

event.

where do you place the reference for the external javascript in the html page?

exactly where you would if it was not external.

else statement

executed only when if statement is false can chain them together

regexp brackets

find a range of characters

\d meta character does what?

finds a digit from 0-9 x="hell1o world" y=/\d/g document.write(x.match(y))--> 1

\W meta character does what?

finds a non-word character x="hello world!%" y=/\W/g document.write(x.match(y))--> !,%

\0 meta character does what?

finds a nul character

. meta char does what?

finds a single character (can be used in combination) except newline or other line terminators x="hello world" y=/h.l/g document.write(x.match(y))--> hel

\w meta character does what?

finds a word character (a-z,A-Z,0-9) x="hello world!%" y=/\w/g document.write(x.match(y))--> h,e,l,l,o, ,w,o,r,l,d

[]

finish this minimalist way of declaring an initially empty array. var arMyArray = ??;

What are the two methods common to most controls?

focus //Brings focus to the control blur //Removes focus from the control

loop is a special kind of loop in JavaScript. The loop is a pre-test loop (like a while loop) that combines initialization, condition, and iteration statements.

for

"for" loop construction

for (var number = "0"; number <= 12; number = number +2) show (number); Part 1: initializes loop Part 2: checks whether loop must continue Part 3 updates the state of the loop number of iterations is known

/

for division

for (statement 1; statement 2; statement 3) { the code block to be executed }

for loop statement 1 (multiple and optional) - before the loop (the code block) starts statement 2 = defines the condition for running the loop statement 3 - executed each time after the loop has been executed

*

for multiplication

-

for subtraction

loop through array

for(i=0; i < array.length; i++){ console.log(array[i]); }

for/in loop to get properties

for(var property in object) { console.log(property); } will print all the properties

for/in loop to get values

for(var x in object) { console.log(object[x]); }

Looping structures in JavaScript?

for, while, do-while

What are the main collections of the document object

forms, images and links

A JavaScript ____ is a block of code designed to perform a particular task

function

JavaScript code inside a _____, can be invoked later, when an event occurs.

function

write some small code with a parameter list in it.

function (a, b, c) {}

A JavaScript function is defined with the ___keyword, followed by a ____, followed by parentheses.

function , name

write out a constructor containing the following parameters

function CustomerBooking (bookingId, customerName, film, showDate) { this.customerName = customerName; this.bookingId = bookingId; this.showDate = showDate; this.film = film; }

private variable

function Person(first,last) { this.firstName = first; this.lastName = last var bankBalance = 7500; } bankBalance is private, but can be accessed by calling a method that's inside of Person to return it. Methods can be made private the same way (using var).

custom class constructor

function Person(name, age) { this.name= name; this.age = age; }

syntax

function calling

Write a one-line piece of JavaScript code that concatenates all strings passed into a function

function concatenate() { return String.prototype.concat.apply('', arguments); }

method

function that is the property of an object

<button onclick="myFunction('Harry Potter','Wizard')">Try it</button> <script> function myFunction(name,job) { alert("Welcome " + name + ", the " + job); } </script>

function with arguments

anonymous functions

functions created without names

What Date object method is used to return the number of milliseconds since the start of GMT?

getTime();

What are the available get methods for a Date object?

getTime(); getFullYear(); //Returns 4 digit year getMonth(); //Returns months, starts with 0 for January getDate(); // Returns day of the month getHours(); //Returns hours in the day getMinutes(); //Returns the minutes in the current hour getSeconds(); //Returns seconds in the current minute getMilliseconds(); //Returns milliseconds in the current second

% operator

gives the remainder of two numbers, same precedence as * and /

global,properties,function,invoked

global,properties,function,invoked The JavaScript "Scope chain" is: A chain of objects that includes the G? object and the unnamed/unreferenceable objects whose pr? are the local variables of each f?. This chain grows each time a function is i?. Keep in mind that each function has its own scope chain: the variables it can see.

>

greater than

1

he's saying that, objects besides teh date type involve an object-to-number conversion. But using + on Date objects involve object-to-string conversions. (just enter "1")

toString,valueOf,TypeError,toString,valueOf

how does it cnovert an objet to a string? it looks for a ??? method and runs that. if it can't find that method, it runs teh object's ??? method if it has one, adn converts the primitive result of that method to a string. And what if the object has neither of those methods? it throws a ????. and the way j/s converts objects to numbers is about the same as how it converts objects to strings. But instead of calling teh object's ??? method first, it calls its ???? method first.

How do you code an If Else If statement in JavaScript?

if (condition) { } else if (condition) {}

How do you code an If statement in JavaScript?

if (condition) {}

if (boolean) { console.log("") }

if statement format

automatic type conversions

if you add a non-string to a string, the value is converted to a string before addition if you multiply a number by a string, JS tries to make a number out of a string (ex. "5" = 5)

is the logical not operator. tests a conditional statement and returns the opposite,soifaconditionalstatement is true, the operator will return a false, and if a conditional statement is false, the operator will return a true.

if(!(a==1&&b==2)){...

Example of a conditional statement where "i" is NOT equal to 5

if(i!=5)

what are the conditional statements in javascript?

if,if...else,if...else if....else,switch

if (condition1) { code to be executed if cond 1 is true } else if (condition2) { code 2b executed if cond 2 is true } else { code if neither 1 or 2 are true }

if. else if. else statements

Change the source file of an image to "pic_bulboff.gif". The variable which refers to the HTML image is 'image'.

image.src = "pic_bulboff.gif";

"whatsupniggaz".substring(0,7) would produce the word whatsup out of that phrase. How do u determine the values to find substrings?

imagine a line between each character including spaces....it starts with 0 and goes from there

When do javascripts execute?

immediately. as the page loads into the browser.

<script src="myScript.js"></script>

import javascript file

where does JavaScript code go?

in a <script> tag. the type attribute should be equal to "text/javascript". be sure to close your script tag once the JavaScript code has ended

where, commonly, does JavaScript go?

in the head or at the bottom of the page

where can you put the <script> tag?

in the head or in the body

where do you place functions and why?

in the head section, this way they are all in one place, and they do not interfere with page content.

controls/components

interactive objects

objects

invisible identities with defined capabilities

===

is strictly equal to (opposite of Ruby)

join() does what?

joins all elements of an array into a string array.join(seperator) x=["1","2","3"] document.write(x.join(" and ")) --> 1 and 2 and 3

concat

joins two arrays together

object have 2 things

keys and values, {"key":"value"}

programming language

language designed for programming computers

<=

less than or equal to

Nested Loops

loop within a loop. Inner and Outer loops MUST use different iteration variables or else they will interfere with each other

for (var i=0; i<cars.length;i++) { document.write(cars[i] + "<br>"); }

loops in JS

what does the for loop do?

loops through a block of code a specified number of times

what does the while loop do?

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

How to add a function as a property in a JavaScript object?

man.getName = function() { return man.name; }

what does the n{x,} quantifier do?

matches any string that contains a sequence of atleast X n's [x must be a number] x="100, 1000 or 10000" y=/\d{3,}/g document.write(x.match(y))--> 100,1000,10000

what does the n* quantifier do?

matches any string that contains zero or more occurrences of n x="hello world" y=/lo*/g document.write(x.match(y))--> lo,l

what does the n? quantifier do?

matches any string that contains zero or one occurences of n x="hello world" y=/lo?/g document.write(x.match(y))--> lo,l

what does the n$ quantifier do?

matches any string with n at the end x="hello world" y=/ld$/g document.write(x.match(y))--> ld

getElementById?

method that lets you grab any element that has an id.

are functions that perform a task. are functions that always contain arguments contained within a parenthesis, or an empty parenthesis if there are no arguments.

methods

/*

multi-line commenet

*

multiplication

How do you return the first element of an array with a name myArray?

myArray[0]

same value as

myName === yourName

call function

myName("Sara");

numerical sort

my_array.sort(function(a,b) { return a -b; }

Using the example below, call last name for variable "person" (assign that to a new variable called "name". Use 2 different methods. var person={ firstname : "John", lastname : "Doe" }

name=person.lastname; name=person["lastname"];

Variables

names in programming technology that means that values vary

Variables

names in programming terminology meaning that values vary

finding browsers and app.name?

navigator.appName - name navigator.appVersion - version #

determining if cookies are enabled?

navigator.cookieEnabled - true or false

;

need ____ to end inputs/answers

tests

newtest

does JavaScript require you to end lines with a semicolon?

no, but it is considered good practice and I recommend that you do

is there a standard that applies to the navigator object?

no, therefore determining browsers becomes quite an ordeal.

is JavaScript the same thing as Java?

no. not at all. Java is a powerful, complex language, much like C, C++, and other similar programming languages. JavaScript is easy to learn

can you have multiple statements on one line without using semicolons?

no. you must use semicolons for JavaScript to interpret the end of a statement if more than one statement is going to be on the line

Output of: var myString = 'Amy'; var myStringCpy = myString; var myString = null; console.log(myString, myStringCpy);

null Amy

real number (floating point)

number greater than or equal to 0 and less than 1

parseInt()

number is inside parentheses, takes Int out of string, if two arguments given, 2nd arg is base of number, string must start with a number

length

number of elements in an array

What are the values produced by 'typeof'?

number, string, boolean, undefined, function, object

Six Basic Types of Data

numbers, strings, booleans, objects, functions, undefined values

number values

numerical values that can be added, subtracted, multiplied, and divided

What is the syntax for the standard event model and who supports it?

obj.addEventListener('click', functionToExecute , ' capturing' ); To remove an event just use removeEventListener with the same arguments as you used to add it.

boolean

only true or false

boolean values

only two values: true and false

Which event for validating a form?

onsubmit

concatenation

operation that joins strings using +

binary operators

operators that use two values (ex. "Hello" + "You")

Any time you find yourself typing the same thing, but modifying only one small part, you can probably use a function. The 'small part' that you find yourself modifying will be the _______. And the part that you keep repeating will be the code in the reusable block - the code inside { }.

parameter

dot model?

parent object.child object. [which element applies to].style.fontFamily="none"

dot notation?

parent object.child object[which item applies to].style object.property

$.each

passing parameters, such as the iterator $.each( html, function( i, el ) { nodeNames[ i ] = "<li>" + el.nodeName + "</li>"; }); This is different than $(selector).each()

the Math object allows you to?

perform mathematical equations and tasks.

what does the i modifier do?

performs a case insensitive search /regexp/i x="hello world" y=/world/i document.write(x.match(y))--> world

what does the g modifier do?

performs a global match (instead of stopping at first found) /regexp/g x="hello world" y=/o/g document.write(x.match(y))--> o,o

console.log

printing command

common term for using the console.log() command

printing out

console.log(yay);

prints the value stored in the variable yay to the computer screen

console.log()

prints to the computer screen

console.log("yay");

prints yay to the computer screen

Indexing

process of creating a sequence of names by associating a base name with a number

empty statement

produced by a lone semicolon can be used in a loop to increment variable to desired value and then stop (similar to a break)

What is the command to display a prompt?

prompt("Text Here");

Use the prompt command to ask the user where they are from

prompt("Where are you from?");

ask for inputs

prompts ask for___ prompt( )

regexp means what?

regular expression

shift() method does what?

removes the first elements in an array and returns it [alters original] array.shift() x=["1","2","3"] document.write(x.shift())--->1 document.write(x)--->2,3

pop() does what?

removes the last element of an array and returns it [alters original] array.pop() fruits=["apple","nana","grape","orange"] document.write(fruits.pop())-->orange document.write(fruits())-->apple,nana,grape

&&

requires that all the conditions be true

||

requires that at least one of the conditions be true

getElementById

retrieve element by id

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

return statement

what does the random() method do?

returns a random number between 0 and 1 [use .floor() and * to get a higher number] Math.random() document.write(Math.random())-->0.57

substr(start, length)

returns a substring based on the start and length parameters

what does acos() method do?

returns the arccosine of a number in radians Math.acos(x) document.write(Math.acos(0.64))-->0.87629

what does atan2() method do?

returns the arctangent between positive x-axis and the point Math.atan2(x,y) document.write(Math.atan2(8,4))-->1.1071

what does atan() method do?

returns the arctangent of a number in radians Math.atan(x) document.write(Math.atan(2))-->1.1071

what does cos() method do?

returns the cosine of a number Math.cos(number) document.write(Math.cos(3))-->-0.9899

what does the log() method do?

returns the natural logarithm (base E) of a number Math.log(number) document.write(Math.log(2))-->0.6931

what does min() method do?

returns the number with the lowest value Math.min(x,y,z) document.write(Math.min(10,5,-1))-->-1

what does sin() do?

returns the sine of a number (-1 to 1) Math.sin(number) document.write(Math.sin(3))-->0.1411

what does the source property do?

returns the source of the regexp x=/regexp/gi document.write(x.source)-->regexp

what does sqrt() do?

returns the square root of a number Math.sqrt(number) document.write(Math.sqrt(9))-->3

what does the method tan() do?

returns the tangent of a number Math.tan(number) document.write(Math.tan(90))-->-1.995

what does exp() method do?

returns the value of a user-defined power to eulers number Math.exp(number) document.write(Math.exp(1))-->2.7183

what does pow() method do?

returns the value of x to the power of y Math.pow(x,y) document.write(Math.pow(4,2))-->16

isFinite(x);

returns true if x=number other than NaN, Infinity, or -Infinity

reverse() method does?

reverse the order of elements in an array (first is last, last is first) array.reverse() x=["1","2","3"] x.reverse() document.write(x)-->3,2,1

Math.round

round to nearest whole number

what does floor() method do?

rounds a number to down to the nearest interger Math.floor(number) document.write(Math.floor(5.3))-->5

what does round() method do?

rounds a number to the nearest interget Math.round(x) document.write(Math.round(5.5))-->6 document.write(Math.round(5.49))-->5

what does ceil() method do?

rounds a number upwards to the nearest interger and returns the result Math.ceil(number) document.write(Math.ceil(2.3))--> 3

Math.floor

rounds down

Math.ceil

rounds up

slide show

run a presentation by clicking this button on the view toolbar

for(...;...;...)

same as a while loop, but everything is on one line. 1st part defines a variable, 2nd part check when it ends, 3rd part updater

is just a short program, usually placed within another construct (like JavaScript inside of HTML). Officially, program code is called if you don't have to compile first

script

What are the available set methods for a Date object?

setFullYear(); //Sets 4 digit year setMonth(); //Sets months, starts with 0 for January setDate(); // Sets day of the month setHours(); //Sets hours in the day setMinutes(); //Sets the minutes in the current hour setSeconds(); //Sets seconds in the current minute setMilliseconds(); //Sets milliseconds in the current second

functions

small, simple pieces used to develop & maintain a large program

sort() method does what?

sorts the elements of an array (alphabetical default) [changes original] array.sort(sort function) x=["a","b","c"] y=["a","c","b"] document.write(y.sort())-->a,b,c

SQRT2 is what?

square root of 2 approx (1.414)

octal

start with 0, each place represents a power of 8

how to access an array?

string[array index]

part of a string

substring

"".substring(x,y)

substring code

What String object method is used to return a new string that contains part of the original string from the specified start position?

substring(startIndex);

switch

switch(variable) { case 0: return 0; break; case 1: return 1; break; default: return "unknown"; }

splice

takes out element and move all following array values down one index, 2 args - (starting index, length of splice) 3 args (starting index, length of splice, what you want to insert)

Math.pow

takes the first arg and raises it to the power of the second arg

Function keyword?

tells browser that you are using a function.

function keyword?

tells browser, "this is a function"

Use document.write for ____ only.

testing (if you execute it, on a loaded HTML document, all HTML elements will be overwritten)

what does the exec() method do?

tests for a match in a string (returns matched text if found null if not) y=/regexp/ y.exec(string)

what does the test() method do?

tests for a match in a string, returns true or false (true if found, false if not) y=/regexp/ y.test(string)

what sequence are javascript statements executed in?

the order they are written.

what happens if you add a string and a number?

the result will be a string

JavaScript has dynamic types, which means that __

the same variable can be used as different types.

What is a LEXICAL STRUCTURE of a programming language?

the set of elementary rules that specifies how you write programs in that language

To use an external script, put the name of the script file in ______

the source (src) attribute of the <script> tag.

return a value

the value given by data validation

null

the value of a variable that is defined but has no value

In JavaScript you can always separate statements by semicolon, but you cannot omit ___

the var keyword

What if you don't want the script to execute immediately upon loading a page?

then put it inside a function.

Avoid String, Number and Boolean objects because _____

they complicate your code and slow down execution speed

var myState = "Alabama";

this command stores Alabama in the variable myState

myState.length;

this command will give the length of the string that is stored in the variable myState

what is the purpose of the return statement?

to specify the value that is returned from the function.

decrement

to subtract 1 from a value

What method allows you to set the digit precision of a decimal number?

toFixed(digitCount);

What Number object method is used to round numbers to the specified number of decimal places?

toFixed(digits);

What String object method returns a new string containing the value of the original string but in all lower case?

toLowerCase();

What Number object method is used to return a numerical string with the specified number of significant digits?

toPrecision(precision);

What String object method returns a new string containing the value of the original string but in all upper case?

toUpperCase();

comparing values of a different type

tries to convert one value into the type of the other when null or undefined occur, it is only true if both sides are either null or undefined

How do you throw and catch an exception

try {throw exception;} catch(exception){alert("here is the error");}

Errors

try/catch/finally blocks. Basically, you try to run code (in the try block between the braces), and execution is transferred to the catch block of code when/if runtime errors occur. When the try/catch block is finally done, code execution transfers to the finally code block. This is the same way it works in other languages like C# and Java.

true

two different object variables are equal if and only they refer to the same underlying object. true or false?

boolean

two values (true or false)

sequence of characters ("4" or "Lanstrom")

type: string

instanceof vs typeof

typeof will return "object" for all references except function, instanceof Array

when checking to see if something = something else?

use two equal signs. ==

How do you check if a variable is an object?

use typeof if (bar && typeof bar === "object") { console.log('bar is object and is not null'); }

\D meta character does what?

used for find a non-digit character x="hello world9" y=/\D/g document.write(x.match(y))--> h,e,l,l,o, ,w,o,r,l,d

External scripts are practical when the same code is _____

used in many different web pages

Default (||)

value = v || 10; /* Use the value of v, but if v doesn't have a value, use 10 instead. */

parameters/arguments

values given to functions ex: alert("Avocados"); - Avocados is an argument

JavaScript uses the ____ keyword to define variables.

var

variable keyword?

var

How do you assign the return value of confirm() to a variable?

var answerVar = confirm("Message Text Here");

For a text area, how do you get the current character count for the control?

var areaText = document.getElementById("textAreaId").value; var charCount = areaText.length;

array

var array = [1, "chicken", true];

How do you create an Array object in JavaScript?

var arrayVar = new Array();

Create a Date object for June 28, 2014.

var before = new Date(2014, 5, 28) //months start from 0 (jan=0), days start from 1

add via custom constructor

var bob = new Person("Bob", 27);

How do you parse the date, month and year from a date?

var dateNow = new Date(); var yearNow = dateNow.getFullYear(); var monthNow = months[dateNow.getMonth()]; var dayNow = dateNow.getDate();

What is the format to create a new Date object from a string?

var dateObject = new Date("11/22/2012 18:25:35");

How do you create a new Date object?

var dateObject = new Date(year, month, day, hours, minutes, seconds, milliseconds);

How do you create a Date object in JavaScript?

var dateVar = new Date();

var el = $( "1<br>2<br>3" ); returns what?

var el = $( "1<br>2<br>3" ); // returns [<br>, "2", <br>]

Get the element with id="demo" and store it in the variable elem.

var elem = document.getElementById("demo");

remove element

var element = window.document.getElementById('anId'); element.parentNode.removeChild(element);

objects in object

var friends = {}; friends.bill = { name: "Bill"; age: 25; }

How do you create a function that returns a value in JavaScript?

var functionName = function(param1, param2, paramN) { //Other steps return returnValue; }

How do you create a function in JavaScript?

var functionName = function(param1, param2, paramN) {}

Set the vairable image to store the reference to the HTML element identified with the id="myImage"

var image = document.getElementById('myImage');

while loop in function

var loop = function(){ while(i<10){ console.log(i); i++; } }; loop();

do while loop

var loopCondition = false do { console.log(loopCondition); } while(loopCondition);

variable

var me = "Sara";

What is the syntax of an if statement

var myVariable; if (myVariable == 1) { do something }

How to create a new object in JavaScript?

var obj = new Object(); or var obj = {};

looping through object properties

var objectName = { name: "Morgan Jones", telephone: "(650) 777 - 7777", email: "[email protected]" }; for (var propertyName in objectName) { // Your code here }

How do you declare a variable in JavaScript?

var variableName;

Set variable x to refer to the HTML element identified by "demo"

var x = document.getElementById("demo");

To create an array?

var x = new Array();

creating an uncondensed array?

var x = new Array(); //regular array x[0] = "black"; x[1] = "white"; x[2] = "green"; x[3] = "yellow"; x[4] = "blue"; x[5] = "red";

creating a condensed array?

var x = new array ("white","black","red","green","blue") //condensed array

how do you declare a variable?

var x; declares variable 'x' var x = 5; declares variable x and defines it as equal to the value 5 at the same time var carname; // declare carname var carname = "BMW"; // declare and define carname as equal to the string "BMW"

JavaScript Arrays (Condensed)

var xxx=new Array("xxx");

JavaScript Arrays

var xxx=new Array(); xxx[0]="xxx";

Start the statement with ___ and separate the variables by ___

var, comma

var

variable

var nameName = data

variable code

local variables

variables declared in function definitions must have "var" keyword or it is global

A variable can have _____ during the execution of a JavaScript. A literal is always a____.

variables values constant value

How do you assign actions to the window onLoad event?

window.onload = function() {//actions here}

What is the precursor to jQuery's $(document).ready( ) method?

window.onload(function(){ //Place all code here to run after dom loads });

var message="Hello World"; var x=message.toUpperCase();

x= HELLO WORLD

prompt box syntax?

x="prompt("text here","default value"); if(x!="null" && x!="") { alert("hello "+x+" how are you today?") }

is JavaScript case-sensitive?

yes. date() and Date() are not equal

can an external JavaScript file be accessed?

yes. use <script type="text/javascript" src="file.js"></script>

what do you need to do if there are no variables to pass to the function?

you must still include the parenthesis () at the end of the function name.

conditional variable syntax?

z=(x==y)?5:6 z = 5 if x=y; z = 6 if x!=y;

"Or" operator

||

Boolean operators

&&, ||, !

To make a plus operator add numbers?

var Num = Number(text.value);

scope

where variables can be seen

!

The NOT logical operator

What can a method use 'this' to access? and why?

The object; So that it can retrieve values from the object or modify the object

// add a text here

This is a comment in javascript code.

getMonth()

This is a method of the Date object. It returns a numeric representation of the month (1-12).

<script language="javascript" type="text/javascript"> </script>

This is an HTML tag. The developer can write JavaScript code inside this tag.

Comma

This is used to separate multiple Javascript Event Handlers when they are to act simultaneously

instantiate

To create or manifest

Dot Operator

Used to aid in navigation between elements

How does textNode and innerHtml differ?

Using textNode will convert the objects html to a string whereas innerHtml will give you the content back as html.

How do you assign a default value to a prompt?

Using the second parameter. Example: prompt("Enter Age:", "18");

what are the Rules for JavaScript variable names

Variable names are case sensitive (y and Y are two different variables)

How do you create a single line comment in JavaScript?

With two forward slashes "//"

What is the string escape sequence to insert a carriage return in JavaScript?

\r

prototype

an object

how many scripts can you have in your HTML page?

an unlimited amount

JavaScript variables are _____

containers for storing data

DOM

document object model

token

either a variable name or a literal constant

e is what?

eulers numbers approx (2.718)

indexOf()

finds what is passed in the parentheses and returns the index number

Functions With a Return Value

function xxx() { var x=x; return x; }

parseFloat() does what?

gets a decimal number from a string [not part of the math object] parseFloat(string) document.write(parseFloat("45.1nn"))-->45.1 document.write(parseFloat("45nn"))-->45

How do you code an If Else statement in JavaScript?

if (condition){ } else {}

if/else if/else

if(true) { console.log("true"); } else if(false) { console.log("false"); } else { console.log("unknown"); }

Where do you put javascripts?

in the head or body sections.

document

is our webpage in javascript

"".length

length

//

make comment in JS

unary operators

operators that use only one value (ex. typeof(5))

isNaN(x);

returns true if x=NaN or a non-numeric value such as a string or object

Ways to access the value of a textbox using JavaScript, i.e. <body> Full name: <input type="text" id="txtFullName" name="FirstName" value="Vikas Ahlawat"> </body>

var name = document.getElementById('txtFullName').value; or document.forms[0].mybutton. var name = document.forms[0].FirstName.value;

How do you find an element by type on the page?

var obj = getElementsByTagName('p'); It returns a specific type of array - like object called a node list.

creating a literal array?

var x = ["black","white","red","blue","green"]

Programming

writing a list of instructions to the computer so it can do cool stuff with your information.

x=x+y is the same as what? or x=x/y?

x+=y or x/=y

Variable x refers to a HTML element. Set the color to red.

x.style.color = "red";

Variable x refers to a HTML element. Set the font size to 25 pixel.

x.style.fontSize = "25px";

can a variables value change during the execution of a script?

yes

is javascript case sensitive?

yes

What does "1" + 2 + 4 evaluate to?

124 since 1 is a string then everything is a string

prompt

A input

What does a property have?

A name and a value

psuedo-random numbers

An algorithm produces a sequence of numbers that passes the statistical tests for randomness.

Hyperlink Rollover

An image that changes when the mouse pointer clicks on or moves over a hyperlink graphic.

var person = new Object(); person.firstname="John"; person.lastname="Doe"; person.age=50; person.eyecolor="blue";

Create object and add properties

createPopup()

Creates a pop-up window

hoisting

JS automatically takes variable and declares it at top of function

confirm("are you sure?");

Makes a dialogue pop up asking if the user is sure

Random number generator

Math.random

getDate()

Returns the day of the month (from 1-31)

getUTCDay()

Returns the day of the week, according to universal time (from 0-6)

href

Returns the entire URL

cycling banner

Several graphics that are displayed one after another with a pause between images. The graphics scroll in either a fixed or random order.

Cycling Banner

Several images are displayed one after another with a pause between images. The images scroll in either a fixed or random order.

global

Specifies if the "g" modifier is set

ignoreCase

Specifies if the "i" modifier is set

multiline

Specifies if the "m" modifier is set

<!DOCTYPE>

Tag to identify the type of document

<link>

Tag to link to an external file

$ children

$.children()

$ parents

$.parent()

counts spaces and characters

. length

When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value.

...

array object methods

...

regexp object methods

...

regexp object properties

...

string object methods

...

var carname="toyota";

...

attributes in $

.attr() Get the value of an attribute for the first element in the set of matched elements or set one or more attributes for every matched element.

get by tag name

.document.getElementsByTagName('p')[0];

Extension for Javascript documents?

.js

Extension for javascript document?

.js

JavaScript files have the file extension __

.js

$ propertie

.prop() Get the value of a property for the first element in the set of matched elements or set one or more properties for every matched element.

attributes

.setAttribute('title', 'A link'); .removeAttribute('href');

Split Method

.split(" ") looks for space, takes whatever is before that space, and puts it into an array.

substring

.substring x is where you start chopping and y is where you finish chopping

uppercase and lowercase

.toUpperCase(); .toLowerCase();

$.trigger

.trigger() Execute all handlers and behaviors attached to the matched elements for the given event type.

comment

/* block comment // line comment

multi line comment

/*Comment1 Comment2 . . Comment3 */

How do you insert comments?

//

how are single line comments started?

//

JavaScript is..

1.programming language, and is considered much more difficult 2.client-side programming tool 3.embedded within an HTML page. 4.case-sensitive 5.supported by virtually all browsers 6.an dynamically change HTML 7.can react to events. 8.read and write HTML elements 9.can be used to validate HTML form data.

less than comparison operator

<

Sections of an HTML page where is possible to put JavaScripts

<head> and <body>

Tag to insert JavaScripts

<script>

In HTML, JavaScripts must be inserted inbetween ____ and ____ .

<script> and </script> tags

code to set timer

<set Timeout("<event handler>" <duration>)

What are JavaScript closures? When would you use them?

A closure is the local variables for a function, kept alive after the function has returned, or a closure is a stack-frame which is not deallocated when the function returns. A closure takes place when a function creates an environment that binds variables to it in such a way that they are kept alive after the function has returned. A closure is a special kind of object that combines two things: a function, and any local variables that were in-scope at the time the closure was created. Example: function sayHello(name) { var text = 'Hello' + name; //local variable var sayAlert = function { alert(text); } return sayAlert; } Closures reduce the need to pass state around the application. The inner function has access to the variables in the outer function so there is no need to store the information somewhere that the inner function can get it. This is important when the inner function will be called after the outer function has exited. The most common example of this is when the inner function is being used to handle an event. In this case, you get no control over the arguments that are passed to the function so using a closure to keep track of state can be very convenient. (function() { function foo(x) { var baz = 3; return function (y) { console.log(x + y + (++baz)); } } var moo = foo(2); // moo is now a closure. moo(1); // 7 moo(1); // 8! })();

Array

A collection of similar objects that are accessed by a variable name and an index. When you give several controls the same name, they are considered an ____ of objects. An ___ is required to have an index value that will always start with zero and increase for each object in it.

scripting language

A computer programming language that is typically interpreted into a language the computer can understand without the need of a compiler.

What is an object in JavaScript?

A container for a collection of named values. var man = new Object(); man.name = "Ian"; man.age = "19";

Methods

A function that is a member of an object.

What do all objects created from object literals come with?

A link to the Object.prototype

Parameter list

A list of information that provides a programming method what it needs to perform a specific function correctly. Example: document.write("Hello World");

Errors

A message box that is displayed when something in the script's format or verbage disallows it to run. The two type you'll encounter are called RunTime and Syntax.

When a function is stored as a property of an object, what do we call it?

A method

hasOwnProperty

A method available to all JavaScript objects. Returns a Boolean value indicating whether an object has a property with the specified name.

Term for the symbol when a % is placed between two numbers, causing the computer to divide the first number by the second and return the remainder of that division

A modulo

What is an object in Javascript?

A mutable keyed collection.

Variable

A name that is assigned to a literal value or an object. Once assigned, that name can be used throughout the HTML document to refer to that particular value or object.

What does the 'create' method create?

A new object that uses an old object as its prototype

what range of numbers does the Math.random() function provide

A number between 0 & 1

Infinity

A numeric value that represents positive/negative infinity

what is a prompt box?

A prompt box is often used if you want the user to input a value before entering a page.

Interpretation

A term used by programmers to describe the line-by-line conversion process that occurs automatically at runtime or when the Web browser launches the JavaScript commands that are in the Web file.

what are assignment operators?

Assignment operators are used to assign values to JavaScript variables.

What is AJAX?

Asynchronous JavaScript And XML

onclick="alert('Welcome!')

Click on button

The function object created by a function literal contains a link to that outer context. What is this called?

Closure

segment of the for loop allows you to test a value during each iteration of the loop. As with while loop testing, in the for loop is tested before the loop begins. If is not met, then the loop never executes.

Condition

sup()

Displays a string as superscript text

bold()

Displays a string in bold

16

Even though JavaScript's string methods work solely with a single ?-bit values, some characters require a "surrogate pair", i.e. two ?-bit values.

this keyword

Is a context-pointer and not an object pointer. Gives you the top-most context that s placed on the stack Points to the currently in scope object that owns where you are in the code. When working within a Web page, it usually refers to the Window object. If you're in an object created with the new keyword, the this keyword refers to the object being created. When working with event handlers, the this keyword points to the object that generated the event

==

Is equal to (comparison operator)

===

Is exactly equal to (value and type comparison operator - think about the difference between a number and a string)

What is a DOM level 0 event handler?

It is an old way of adding event listeners to objects. It is 100% supported by browsers but lacks the ability to attach multiple events per click. It has been abandoned in favor of the standard event model. Syntax for dom level 0 is: obj.onclick = function(){ //some code here };

segment of the for loop allows you to execute one or several JavaScript commands (separated by a comma) during each of the for loop.

Iteration

!=

JS not equal (opposite of 2 equals)

!==

JS not equal(opposite of 3 equal)

What Math object method is used to return the absolute value of a given number?

Math.abs(number);

What Math object method is used to return a given number rounded to the next highest integer value?

Math.ceil(number);

What Math object method is used to return a given number rounded to the next lowest integer value?

Math.floor(number);

What Math object method is used to return the highest value from a set of supplied numbers?

Math.max(var1, var2, varN);

What Math object method is used to return the lowest value for a set of supplied numbers?

Math.min(var1, var2, varN);

%

Modulus arithmetic operator (division remainder)

2 reasons to write functions

Most functions are general, manages complexity

What are the available properties for the Number object?

Number.MAX_VALUE Number.MIN_VALUE Number.POSITIVE_INFINITY Number.NEGATIVE_INFINITY Number.NaN

When does the retrieve of a property value bottom out?

Object.prototype

What are functions used to specify the behaviour of?

Objects

Properties

Objects that programmers access to obtain information about the object.

<SCRIPT> tabs

Open and close Java language

window.open("http://www.google.com","_self")

Open google in the current page.

*

Operator for multiplication

-

Operator for subtraction

Comparison Operator

Operator used in logical statements to determine equality or difference (the comparison operator returns true or false)

Assignment Operator

Operator used to assign values to JavaScript variables

Logic Operator

Operator used to determine the logic between variables or values

Arithmetic Operator

Operator used to perform arithmetic between variables and/or values

LN10

Returns the natural logarithm of 10 (approx. 2.302)

pathname

Returns the path name of a URL

exp(x)

Returns the value of Ex

image rollover

The appearance of this term changes when the mouse pointer moves over the image.

What happens when a "submit" button is clicked and how to you set a button to be a submit button?

The form data from the form the button is inside gets sent to the server. the submit button is set by "type=submit" of the button element.

Every function is created with which two hidden properties?

The function's context and the code that implements the function's behaviour

What is the difference in form behavior between the submit button and the submit method

The submit() method, submits the form but does not fire the submit event of the form object; thus, the onsubmit event handler is not called

getDay()

This is a method of the Date object. It returns a numeric representation of the day of the week (1-7).

a

Where is the value PI stored? a) the Math object b) the Number object c) none of the above

What is at the end of every line?

\n

exits you out of the current loop.

break statement

What is the native JavaScript equivalent to jQuery's .prepend( ) ?

el.insertBefore( var_to_insert, el_it_comes_before );

parseInt() does what?

gets a number from a string [not part of the math object] parseInt(string) document.write(parseInt("45.1nn"))-->451 document.write(parseInt("45nn"))-->45

concatenation

joining strings with " " + " "

Variables can be emptied by setting the value to __

null

SQRT1_2 is what?

square root of 1/2 approx (0.707)

object in array

var object { name: "Sara"; age: 21; } var array = [2, false, object]; console.log(array); = [2, false, {name: "Sara", age: 21]}

less than or equal to comparison operator

<=

JavaScripts need to be put in the ____ section of an HTML page.

<body> and <head>

A button that call myFunction when clicked

<button type="button" onClick="myFunction()">Click</button>

Button, label "Click Me!", calls myFunction() when clicked.

<button type="button" onclick="myFunction()">Click Me!</button>

Button with label "Click" which call myFunction() when clicked.

<button type="button" onclick="myFunction()">Click</button>

getUTCDate()

Returns the day of the month, according to universal time (from 1-31)

getDay()

Returns the day of the week (from 0-6)

constructor

Returns the function that created the object's prototype

availHeight

Returns the height of the screen (excluding the Windows Taskbar)

host

Returns the hostname and port of a URL

hostname

Returns the hostname of a URL

getHours()

Returns the hour (from 0-23)

MAX_VALUE

Returns the largest number possible in JavaScript

getMilliseconds()

Returns the milliseconds (from 0-999)

getUTCMilliseconds()

Returns the milliseconds, according to universal time (from 0-999)

getMinutes()

Returns the minutes (from 0-59)

what is a confirm box?

A confirm box is often used if you want the user to verify or accept something.

how do you make comments in JavaScript?

// comments a single line /* comments multiple lines */ // document.write("<h1>Heading</h1>"); this line will not be executed

commenting

// text

What is the invocation operator?

A pair of parentheses that follow any expression that produces a value

getUTCMinutes()

Returns the minutes, according to universal time (from 0-59)

getMonth()

Returns the month (from 0-11)

What does 3+4 + "7" evaluate to?

77, because it computes the number arithmetic before concatenation

What are the two main ways to write faster more efficient code?

#1) Limit the amount of identifier lookups that take place by caching anything used multiple times inside a local variable. #2) Manipulating the DOM as seldomly as possible.

What does a double negative "!!" operator mean?

!! placed in front of something casts the contents to a boolean. EX. var x = 1; console.log(typeof x); //number x = !!x; console.log(typeof x); //boolean

is the logical not equals operator. returns true if two expressions contain different values. If is used on a class, it tests whether the two classes refer to different objects.

!=

Comparison Operators "is exactly not equal to (value and type)"

!==

What is the identity operator for not equal?

!==

not equal to comparison operator

!==

NaN

"Not-a-Number" value

what are variables?

"containers" for storing information.

true or false

"dogs fly" .length> 7

in operator

"name" in person1 The in operator looks for a property with a given name in a specific object and returns true if it finds it. In effect, the in operator checks to see if the given key exists in the hash table.

NaN

"not a number" a type of number all arithmetic operations on NaN result in NaN NaN == NaN is false false when converted to boolean

new element with jquery

$( "<p id='test'>My <em>new</em> text</p>" ).appendTo( "body" );

document ready

$(function() { // Document is ready }); or window.onload = function()

$.ajax()

$.ajax({ type: "POST", url: url, data: data, success: success, dataType: dataType }); url Type: String A string containing the URL to which the request is sent. data Type: PlainObject or String A plain object or string that is sent to the server with the request. success(data, textStatus, jqXHR) Type: Function() A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case. dataType Type: String The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). jqXHR.done() (for success), jqXHR.fail() (for error), and jqXHR.always() returns jqXHR var jqxhr = $.post( "example.php", function() { alert( "success" ); });

$ add element before or after

$.before() $.after()

jquery event

$.bind() $( "#foo" ).bind( "click", function() { alert( "User clicked on 'foo.'" ); }); bind( eventType [, eventData ] [, preventBubble ] ) Bind should be replaced with .on() and .off()

assignment symbol

+

is used to increment a variable. When ++ is placed before a variable, that variable is incremented before the rest of the operation occurs. When ++ is placed after a variable, that variable is incremented after the operation occurs. For example, c=++a*b; would be the equivalent of a=a+1; c=a*b;

++

unary plus. A unary plus really has no effect on an equation, but can be used for emphasis. For example, instead of typing a * b, you could type +a * b and retrieve the same result.

+a

What is a sprite? How is it applied using CSS? What is the benefit?

- A image sprite is a collection of images put into one single image. - Using css positioning you can show and hide different parts of the sprite depending on what you need. - Sprites reduces the number of http requsts thus reducing load time of page and bandwidth

What three things does a reference type consist of?

- Constructor - Method Definitions - Properties

What are the differences between the textarea element and the text element?

- No max length attribute - columns attribute - rows attributes - wrap attribute - soft - CR on client, not on server - hard - carriage returns from wrapping converted to hard returns

what can you do from the windows object

- determine the browser - determine the pages visited - size of the user's screen - change text in browser status bar - change page that is loaded - open new windows

List Windows objects common to all browsers and their scope

- document - all elements and objects on a page - three collections - links, images, forms - navigator - information about the browser & OS - screen - display capabilities - location - current page's location - history - all pages the user has visited

Which object is the global object

- the windows object is the global object - you can access it's properties from anywhere in the web page - you do not need to use the windows. to access the properties and methods

used to decrement a variable. When -- is placed before a variable, that variable is decremented before the rest of the operation occurs. When -- is placed after a variable, that variable is incremented after the operation occurs. For example, c=--a*b; would be the equivalent of a=a-1; c=a*b;

--

If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null.

...

If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.

...

Math object properties

...

RegExp modifiers

...

Variable names must begin with a letter or the underscore character

...

When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed.

...

XMLHttpRequest

...

How to make notes in javascript?

//comment goes here </script>

comment

//this is a comment

null,undefined,undefined

1) Okay, what are the two values that indicate "absence of value"? give the shorter word first. 2) Which one has the "deeper" meaning of "not initialized" or possibly "non existant property or element"? Separate all answers with a comma.

String,Number,Boolean,no

1) Some type conversion idioms: a) x + "" // is same as S?????(x); b) +x // same as N?????(x); c) !!x // same as B??????(x); 2) Do these actually convert the operands? (yes/no)

false,rounding error

1) What's the result of the last expression in this program? 2) Reason: R?????? e???? var x = 0.2 - 0.1; var y = 0.3 - 0.2; x == y; ---------------------------

what are two ways to connect an onclick event to a hyperlink?

1) add an onclick tag inside the "a href" tag 2) add window.document.link[0].onclick = <function>

toPrecision,toExponential,toFixed

1) to convert a number to a string with a specific number of significant digits, use method to??? 2) to convert a number to a string with expo. notation, use method to??? 3) to convert a number to a string with N digits after the decimal point, use to??

structure of a "while" loop

1. counter 2. while loop check 3. counter update number of iterations is not known

JavaScript can...

1. used to make a Web page react when a user clicks on a button. 2.make something move on a page. 3.validate data entered into an HTML form. 4.communicate with the server, and download data in the background while the user is looking at other parts of the page.

exponential

1.34E7

HTML can't..

1.perform any conditional statements in HTML(good morning) 2.test information in HTML. validate 3.perform iterations(hi 5 times) 4.gather information about the computer, the browser, or act based upon that information 5.react to an event, like a mouse click, to perform an action

Errors

200's are success 300 are redirects 400 are client errors 500 are server errors 404 - not found 405 - forbidden 500 - internal server error

How can you express 2000000 in javascript?

2000000.00 or 2.0e6

what will this return? new Date().getUTCFullYear()

2014

Image, id is "myImage", source file is pic_bulboff.gif. Calls the function changeImage() when You click.

<img id="myImage" onclick="changeImage()" src="pic_bulboff.gif">

Input field, type is text, identifier is "numb".

<input id="numb" type="text">

Which element is not included in the elements collection?

<input type="image"/>

What element is most commonly used for form elements and what differentiates the elements?

<input/> is the most common, and the "Type" attribute distinguishes the type of element is displayed.

In the <script> tag, how is the Src attribute used?

<script src="fileName.js"> //Used to denote external file for script use

Script in an external file MyScript.js

<script src="myScript.js"></script>

calling an external javascript file syntax?

<script type="text/javascript" src="javascript.js"> </script>

how should an external javascript be referenced?

<script type="text/javascript" src="xxx.js"></script>. name the file with a .js extension.

How do you set the background color?

<script type="text/javascript"> document.bgColor = 'RED'; </script> (i.e. window.document.bgColor='RED';)

how should you prevent your JavaScript code from being seen on browsers that do not support JavaScript?

<script type="text/javascript"> <!-- JavaScript code here // --> </script> the "//" is the comment symbol for JavaScript. this method will make sense as you go along

equal to comparison operator

==

s the logical equals operator. tests whether two expressions have the same value. If used on a class, it tests whether the two classes refer to the same object.

==

What is the identity operator for equals?

===

What will attempting to retrieve values from 'undefined' throw?

A 'TypeError' exception

What are child selectors in CSS?

A child selector is used when you want to match an element that is the child of another specific element. The parent and child selectors are separated by spaces.

What is a JavaScript object?

A collection of data containing both properties and methods. Each element in a document is an object. Using the DOM you can get at each of these elements/objects and do some cool sh*t.

Slide show

A collection of images that cycle when the user clicks on the image or hypertext.

Method

A command that tells how an object is to be acted upon.

Scripting language

A language that does not have to be run through a compiler for it to be understood. Web browsers take the human-readable format and convert it into machine-readable format "on the fly."

Programming language

A language that has to be converted from a human-readable format into machine-readable format. This process is accomplished by using a compiler to complete the operation.

Comment

A line of text set aside by double slashes (//). That line of text will be left in the script but will not be used as part of the event.

Real number

A real number that has a decimal portion. Also called a floating point number.

How does a reference type name differ from that of a variable?

A reference type name starts with an upper case letter

What does an inner function enjoy?

Access to the parameters and variables of the functions it is nested within

prototype

Add a method to all objects in class using prototype Dog.prototype.bark = function() { console.log("Woof"); };

What can the plus operator do?

Add numbers, or plug strings together

+

Addition arithmetic operator (can be used for numbers and strings) [operator]

.appendTo( "body" )

Adds an elment to another lement

unshift()

Adds new elements to the beginning of an array, and returns the new length

push()

Adds new elements to the end of an array, and returns the new length

splice()

Adds/Removes elements from an array

Binary code

After JavaScript code has been translated by interpretation, it becomes machine-readable code.

what are the three kinds of pop up boxes?

Alert box, Confirm box, and Prompt box

What happens with the "reset" button is clicked

All form elements are cleared and returned to their default values

prototype

Allows you to add properties and methods to an object

When would you use var in your declaration and when you wouldn't?

Always use var. Not using var for variable declaration will traverse scopes all the way up until the global scope. If the variable with that name is not found it will declare it in the global scope. And you don't want to implicitly declare variables in the global scope anyways, it's a bad practice!

what is an alert box?

An alert box is often used if you want to make sure information comes through to the user.When an alert box pops up, the user will have to click "OK" to proceed.

text fields

An input control that allows someone to type a string value into a specific location on a web page.

checkboxes

An input control that allows the user to select any of the listed options from a set of options.

radio buttons

An input control that allows the user to select just one option from a set of options.

Objects

An object is a referenceable container of name/value pairs. The names are strings (or other elements such as numbers that are converted to strings). The values can be any of the data types, including other objects.

What can a property value be?

Any JavaScript value except for 'undefined'

A property name can be what?

Any string, including the empty string.

Where can a function literal appear?

Anywhere that an expression can appear

What can functions be passed as?

Arguments to functions

Operators manipulate or identify variables.two categories: binary and unary.

Arithmetic Operators

what are arithmetic operators?

Arithmetic operators are used to perform arithmetic between variables and/or values

Accessing attributes

Array-notation and dot-notation are interchangeable (as long as the key/attribute is a legal identifier). Objects and hashtables are the same thing.

What are the object types in Javascript?

Arrays, functions, regular expressions and objects.

How does the flow of a program work

As the code executes down the body of the code it iterates through each line and executes it one by one. When it encounters a function call it jumps into that function definition and the control of the program flow is then given to that function to execute. While the function is running the main program must remember the point where it jumped into the function and what was going on there. This includes things like the variables available and their state. The place where this is stored is called the stack. Once the body of the function called finishes executing, or a return keyword is hit, the control is returned to the main routine from the function using it.

$.is()

Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.

add a class

ClassName = function(prop1, prop2){ this.prop1 = prop1; this.prop2 = prop2; this.printProp1 = function(){ } }

clearTimeout()

Clears a timer set with setTimeout()

String()

Converts an object's value to a string

toDateString()

Converts the date portion of a Date object into a readable string

toTimeString()

Converts the time portion of a Date object to a string

var name = "Sangkhim"

Create a variable and assign a value into it.

var arrayVar = new Array("red","blue","green");

Create an array with 3 values inside.

Initializing

Declaring variables with initial values

decodeURIComponent()

Decodes a URI component

unescape()

Decodes an encoded string

--

Decrement arithmetic operator

cookieEnabled

Determines whether cookies are enabled in the browser

alert()

Displays an alert box with a message and an OK button

global

Do undeclared (implicitly declared) variables in functions have global or local scope? Here's a fragment for reference. function a() { var thisIsLocal = 5; thisIsGlobal = 4; } a(); thisIsLocal; thisIsGlobal;

What does HTML DOM stand for?

Document Object Model

What is the DOM?

Document Object Model

DOM

Document Object model

what does D.R.Y stand for

Don't Repeat Yourself

escape()

Encodes a string

eval()

Evaluates a string and executes it as if it was script code

Event bubbling

Event bubbling describes the behavior of events in child and parent nodes in the Document Object Model (DOM); that is, all child node events are automatically passed to its parent nodes. The benefit of this method is speed, because the code only needs to traverse the DOM tree once. This is useful when you want to place more than one event listener on a DOM element since you can put just one listener on all of the elements, thus code simplicity and reduction. One application of this is the creation of one event listener on a page's body element to respond to any click event that occurs within the page's body.

<div onclick='clickFunction()'>My test</div>

Execute a function when the user click on a div.

<div onmouseover='overFunction()'>My test</div>

Execute a function when the user mouse go over a div.

parseInt

Fill in the question marks: p????Int ("2") + 8 = 10

Number

Fill in the question marks:to spell out a JavaScript constructor method. N????? ("2") + 8 = 10

x=document.getElementByID("demo")

Find element

xObj["prop 1"]

Finish the expression to print the value of the object's only property to the console. var xObj= { "prop 1":13 }; console.log(xObj???? );

new Date(2013,11,25,0,0,0);

Finish the following statement to define a variable set to midnight of Christmas Day, 2013. Omit the milliseconds argument. var x = ??; ------

JavaScript is the default language for which browsers?

Firefox and Chrome

var myDiv = document.getElementById("myDiv");

Get an element from an HTML page.

document.getElementById("demo").innerHTML="My First JavaScript Function

Get and change content in one line

Some earlier versions of browsers do not support JavaScript, and some HTML validation programs do not know how to ignore JavaScript. you can place HTML comment tags around the JavaScript so that you can still validate.<!--

HTML comment tags

recursion

Having a function repeatedly call itself until it sees a reason to stop doing so. When making recursive functions, we consider the following: What is the base case? The base case occurs when the condition is satisfied. This is the last step of the loop. The function simply does some action and ends. What is recursive case? The recursive case occurs when the condition is not satisfied yet. Here, the function does some action and then continues the loop by calling itself. How will data be passed between the different calls of the function? Recursive functions pass data with arguments and return values, rather than variables. WARNING: Make sure your code will reach the base case. Otherwise, the loop will run forever and crash your browser.

Explain hoisting in JavaScript

In JavaScript, function declarations (and their bodies) and variable declarations are 'hoisted' (silently moved to the very top of the scope).

appName

Returns the name of the browser

extending Class methods using 'prototype'

In general, if you want to add a method to a class such that all members of the class can use it, we use the following syntax to extend the prototype: className.prototype.newMethod = function() {statements; };

constructor

In object-oriented programming, a constructor in a class is a special type of subroutine called at the creation of an object. It prepares the new object for use, often accepting parameters which the constructor uses to set any member variables required when the object is first created. It is called a constructor because it constructs the values of data members of the class.

What is the best practice, in terms of data integrity, for working with objects?

In order to get and set values of an object you should create a well defined interface. An interface is a set of methods that you use to read and manipulate the properties / state of an object. In other languages these are called getters and setters or accessers and mutators.

Where is the <script> tag located in javascript?

In the head or body element. Usually head.

a = (b == 1 ? 1 : 2)

In this example, if b is equal to 1, a is set to one. Otherwise, a is set to 2.

Where can functions be stored? (3 places)

In variables, objects, and arrays

++

Increment arithmetic operator

Array

Indexed

undefined

Indicates that a variable has not been assigned a value

What are the 3 shortcuts for Number object properties?

Infinity //Represents Number.POSITIVE_INFINITY -Infinity //Represents Number.NEGATIVE_INFINITY NaN //Represents Number.NaN

segment of the for loop occurs before the for loop begins. This allows you to any variables (separated by a comma), declare any variables of the same type (separated by a comma), or call any functions before the loop starts processing.

Initialization

Different ways to add CSS to web page

Inline: HTML elements may have CSS applied to them via the STYLE attribute. Embedded: CSS may be embedded in a Web page by placing the code in a STYLE element within the HEAD element. Linked: CSS may be placed in an external file (a simple text file containing CSS) and linked via the link element. Imported: Another way to utilize external CSS files via @import.

+

Insert a single unary operator such that the equation yields 10: ?"5" + 5 = 10

Control elements

Interactive objects contained within a JavaScript form. These objects must be given a name so they can be referenced within the JavaScript code.

Objects

Invisible entities that have a defined set of capabilities.

>

Is greater than (comparison operator)

>=

Is greater than or equal to (comparison operator)

<

Is less than (comparison operator)

<=

Is less than or equal to (comparison operator)

!=

Is not equal to (comparison operator)

Should you put JavaScript in separate file?

It depends on many factors 1. Caching When you separate your javascript or css into separate files then it will be cached in the browser and when a new request arrives there is no need to download a new one from the browser. But in the case of an inline coding each time the page is requested the content will be downloaded which will increase the bandwidth usage. 2. Reduce HTTP request By making an inline coding you can reduce the number of HTTP requests which is one page optimization technique. 3. Maintainability By making external javascript and css file it will be easier to maintain the code. You don't have t change each page for the changes to be applied. 4. Minification Minification is the practice of removing unnecessary characters from code to reduce its size thereby improving load times. When code is minified all comments are removed, as well as unneeded white space characters (space, newline, and tab). In the case of JavaScript, this improves response time performance because the size of the downloaded file is reduced.

What two undesirable things does the 'for in' statement do?

It includes the functions and prototype properties

What happens if an invocation expression contains a refinement?

It is invoked as a method

What happens if a function is not given a name?

It is said to be 'anonymous'

What is a modulo (%)?

It is used to find the remainder of something. Examples: 17 % 5 = 2 ........since 17 divided by 5 is 3 with a remainder of 2 20 % 7 = 6......since 20 divided by 7 is 2 with a remainder of 6

When creating a jQuery plugin why do you wrap the main behavior in "return each"

It makes the function work on more than just one item in case the selector returns more than one thing in the selected collection. Otherwise it would only

What does JavaScript do to the DOM?

It manipulates the DOM/ changes the HTML contents

What is Lexical Scoping

It means the when a function executes it uses the data members that were around at the time it was defined, not when it is actually called. Aka, functions take a snapshot of whats going on around their definition when they are called. This is what is know of as their 'scope'. Scope is basically what information the function knows about when it executes. As stated above, this has to do with what is around at the time of their definition.

If we try to retrieve a property value from an object, and the object lacks the property name, what happens?

JavaScript attempts to retrieve the property value from the prototype object

Discuss scoping in JavaScript

JavaScript has lexical scoping based on functions but not blocks.

booleans,strings,numbers

JavaScript's primitives consist of b???, s???, n??? and the types-values null and undefined.

join()

Joins all elements of an array into a string

concat()

Joins two or more arrays, and returns a copy of the joined arrays

concat()

Joins two or more strings, and returns a copy of the joined strings

literal notation

Literal notation is where we declare the object, and, at the same time, define properties and values in the object. It makes use of { }. var apple = { color: "red", age: 1 };

assign()

Loads a new document

go()

Loads a specific URL from the history list

forward()

Loads the next URL in the history list

back()

Loads the previous URL in the history list

what are logical operators?

Logical operators are used to determine the logic between variables or values.

allow you to repeat a line of code either for a number of times or until a condition is met. For example, if you want to scroll through the radio buttons or repeat a process several times, then you need to use this

Loops

Condition

Made up of two tokens and a relational operator. This statement tells the browser that if this is met, then preforms this function; if not, preform a different function.

Relational operators

Make comparisons between numerical values (<, <=, = =, !=)

Relational Operators

Make comparisons between numerical values (<, <=, ==, !=)

Since functions are objects, what can they have?

Methods

________ are actions objects can perform.

Methods

car.start() car.drive() car.brake()

Methods. Performed at different times

What is JavaScript namespacing?

Namespacing is used to bundle up all your functionality using a unique name. In JavaScript, a namespace is really just an object that you've attached all further methods, properties, and objects. It promotes modularity and code reuse in the application.

does JavaScript have classes?

No, JavaScript has an equivalent named a reference type.

is using a semi colon at the end of a statement mandatory>

No, but its good practice and it allows you to write multiple statements on a line.

can the external script contain the <script></script> tags?

No.

!==

Not equal to

Function paramaters

Not strict. Excess params ignored. Missing params get undefined. Auto-added to the "arguments" array.

Number Type

Only floats (no integers)

alert("welcome to my website!");

Open a popup containing simple text.

confirm("Are you sure?");

Open a popup to ask the user to click ok or cancel.

parseFloat()

Parses a string and returns a floating point number

log(x)

Returns the natural logarithm (base E) of x

What is the difference between pascal casing and camel casing.

Pascal casing is the same for all intensive purposes except fot the fact that the first letter is capitalized. Javascript uses this for object naming.

class inheritance

Penguin.prototype = new Animal();

g

Perform a global match (find all matches rather than stopping after the first match)

i

Perform case-insensitive matching

m

Perform multiline matching

Operators

Placed between two tokens in a conditional statement so a comparison may be made.

toString

Provide the entire method name for the following statement, which converts a date to a string. myDate.to??????();

print()

Prints the content of the current window

Object Oriented Programming

Programming based around objects and methods on those objects

_______ are values associated with objects.

Properties

car.name = Fiat car.model= 500

Properties. Values differ from car to car

replace()

Replaces the current document with a new one

Math object?

Provides you properties and methods for mathematical constants and functions

What's the difference between standards mode and quirks mode?

Quirks Mode is a default compatibility mode and may be different from browser to browser, which may result to a lack of consistency in appearance from browser to browser.

What is it called to inspect an object to determine what properties it has?

Reflection

shift()

Removes the first element of an array, and returns that element

pop()

Removes the last element of an array, and returns that element

while(i<10) {}

Repeat an action as long as the variable i is lesser than 10.

b

Replace the ? below with the regex _anchor character_ that will pick the space-delimited Maggie out of this morass. var t = "Aremaggieyou there Maggie?"; t.search(/\?maggie\?/i);

\

Replace the ? to make the following statement free of syntax errors. var x = 'Don?'t do that." ----

NaN

Represents a "Not-a-Number" value

POSITIVE_INFINITY

Represents infinity (returned on overflow)

NEGATIVE_INFINITY

Represents negative infinity (returned on overflow)

resizeBy()

Resizes the window by the specified pixels

resizeTo()

Resizes the window to the specified width and height

return x

Return statement - return value back to where the call was made

E

Returns Euler's number (approx. 2.718)

PI

Returns PI (approx. 3.14)

closed

Returns a Boolean value indicating whether a window has been closed or not

abs(x)

Returns the absolute value of x

match()

Searches for a match between a regular expression and a string, and returns the matches

search()

Searches for a match between a regular expression and a string, and returns the position of the match

replace()

Searches for a match between a substring (or regular expression) and a string, and replaces the matched substring with a new substring

setUTCMilliseconds()

Sets the milliseconds of a date object, according to universal time

slice()

Selects a part of an array, and returns the new array

setMinutes()

Set the minutes of a date object

setUTCMinutes()

Set the minutes of a date object, according to universal time

setUTCSeconds()

Set the seconds of a date object, according to universal time

focus()

Sets focus to the current window

You use the double slash (//) to comment part of a line.

Single Line Comments

//

Single line comment

// a;sldkfja;lsdjkf;alsfkdj

Single line comment

sort()

Sorts the elements of an array

constructor function

Special function for creating and initializing a new object

Methods

Specialized functions within the object that call upon the services of the object. This is invoked after you enter the name of the object followed by a period. Example: document.write

substring

Substring is a JavaScript function that picks a segment of a string between a start and end position.

-

Subtraction arithmetic operator

if(name=="Otdom"){ }

Test the value of a variable.

exec()

Tests for a match in a string. Returns the first match

test()

Tests for a match in a string. Returns true or false

/

Text between a pair of quotes signals a string. Text between a pair of ? signals a regular expression. Type the character. ---

What are the common properties and the object do you use to check the details of a person's browser?

The "navigator" object and the use of two properties; "appName" & "userAgent"

What does the "this" keyword refer to?

The "this" keyword refers to the object instance of the reference type

script

This element is used to add the script right into the page

&&

The AND logical operator

What does the following CSS do? P {font-family: Verdana, Arial, Helvetica;}

The CSS sets the font for the P element. If available in the browser, Verdana is used. If Verdana is not available, Arial is used. If Arial is not an option, Helvetica is utilized.

What is the DOM?

The Document Object Model (DOM) is an API for manipulating HTML and XML documents. It provides a structural representation of the document, enabling you to modify its content and visual presentation by using a scripting language such as JavaScript.

What are function objects linked to?

The Function.prototype

||

The OR logical operator

hyperlink rollover

The appearance of an image changes when the mouse pointer clicks on or moves over a hyperlink.

Image Rollover

The appearance of an image changes when the mouse pointer moves over an image.

<SCRIPT> and </SCRIPT> tags

The beginning and end tags that are necessary in a Web document for a JavaScript statement to be executed. JavaScript code is placed within the beginning and ending tag.

Return values

The default value is undefined, except for constructors, where the default return value is this.

What is the importance of the HTML doctype?

The doctype declaration should be the very first thing in an HTML document, before the html tag. The doctype declaration is not an HTML tag; it is an instruction to the web browser about what version of the markup language the page is written in. The doctype declaration refers to a Document Type Definition (DTD). The DTD specifies the rules for the markup language, so that the browsers can render the content correctly.

What represents the page in the BOM

The document object

What does invoking a function suspend and what does it pass?

The execution of the current function; the control and parameters to the new function

What's the difference between !!(obj1 && obj2) and (obj1 && obj2)

The first returns a "real" boolean value, because you first negate what's inside the parenthesis, but then immediately negate it again. So it's like saying something is "not not" truth-y, making it true. The second example simply checks for the existence of obj1 and obj2, but might not necessarily return a "real" boolean value, instead returning something that is either truth-y or false-y.

Function shorthand

The function statement is a shorthand for the function operator form: var name = function name (argumentlist) block ;

lastIndex

The index at which to start the next match

How can you tell the difference between a property and a method?

The method ends with ()

What are the four patterns of invocation in JavaScript?

The method, function, constructor, and apply invocation patterns

What can you select when you make a new object?

The object that should be its prototype

Difference between window.onload and onDocumentReady?

The onload event does not fire until every last piece of the page is loaded, which includes CSS and images, which means there's a huge delay before any code is executed. onDocumentReady allows us to just wait until the DOM is loaded and is able to be manipulated

Event

The operating systems response to the occurrence of a specific condition.

Data validation

The process of checking user input data to make sure it exists and is accurate.

Instantiate

The process of creating a new object and assigning it a value.

What happens if we add a new property to a prototype?

The property is immediately visible to all the objects that are based on that prototype

What are the four parts of a function literal?

The reserved word 'function'; The optional function name; The set of parameters; A set of statements

What happens and what is it called when a property value doesn't exist anywhere on the prototype chain?

The result is the 'undefined' value; it is called 'delegation'

Syntax

The rules of grammar for a scripting language.

What is the <noscript> tag used for?

The text between the opening and closing tag is displayed if JavaScript is disabled or otherwise not available

source

The text of the RegExp pattern

Difference between undefined and null

The value of a variable with no value is undefined (i.e. not been initialized). Variables can be emptied by setting their value to null. === will check specifically for undefined/null, == will return true for either value. undefined and null are two distinct types: undefined is a type itself while null is an object.

parameter

The variable name that will be given to an argument passed to the function

What is the top level of the BOM and what is its purpose

The window object which represents the frame of the browser. Everything associated with it including the scroll bars, navigator bar icons and so on.

comments

These are human readable notes inside of programming code. These are inserted by the developer to help explain some parts of the code. The software that runs the program does not display or take into account these sections. They are usually short and to the point.

How are numbers, strings, and booleans NOT object-like?

They are immutable.

What is different about the parameters of a function than those of ordinary variables?

They are not initialised to 'undefined', but are initialised to the arguments supplied when the function is invoked

What do simple types and object types have in common? How are simple types "object-like"?

They both have methods.

What is special about functions?

They can be invoked

What makes the identity operators different from the standard equality operators?

They do not perform type coercion. //Eg. If data types don't match they fail the comparison

How are numbers, strings, and booleans object-like?

They have methods.

Why should global variables be avoided?

They weaken the resiliency of programs

['white', 'black', 'gray'];

This array has (white black and gray) string values, using single quotes

function

This is a coded construct that has a name, takes zero or more parameters and contains coded instructions of something to do like calculate a total cost of items bought. It is enclosed inside opening and closing curly brackets. Another name for this is a method.

For Loop

This is a coding structure that allows something to be processed over and over for as long as a condition is met. An example is when we need to access all items in an Array to display a list of items bought.

What is Strict Mode in JavaScript?

Throws errors for actions that are silly but didn't previously throw an error, for potentially unsafe actions. Disables functions that are poorly thought out.

Increment

To add one member to a value.

Output of: var object1 = { same: 'same' }; var object2 = object1; console.log(object1 === object2);

True

Output of: var price1 = 10; var price2 = 10; var price3 = new Number('10'); console.log(price1 === price2); console.log(price1 === price3);

True False, because price3 contains a complex number object, and price1 is a primitive value.

What values can confirm() return?

True or false

What are the four attributes of the <script> tag?

Type, Src, Charset, and Defer

interact with only one variable

Unary operators

when do you use the If...else if...else statement?

Use the if....else if...else statement to select one of several blocks of code to be executed.

How does variable scope work with functions?

Variables created outside of any function are accessible globally, anywhere. Variables created inside a function are available only within that function and its descendants.

Global Function

Variables declared outside a function that can be used throughout the program

Explain the difference between visibility:hidden; and display:none; ?

Visibility:Hidden; - It is not visible but takes up it's original space. Display:None; - It is hidden and takes up absolutely no space as if it was never there.

literals,keywords,variables

What do JavaScript's _primary expressions_ consist of (3)? - Li? : 2, "hi",/abc/ - language ke?s: , i.e. true/false,null,this - v? names: sum, someDiv

2

What does the regex * operator mean? 1) Same as Word's wildcards: any string of characters 2) Zero or more instances (i.e. {0,}) of previous character. 3) None of the foregoing.

c

What objects are parsetInt and parseFloat members of? a) Number object b) Object object c) no object (they're global functions)

-0

What value results when a JS math operation produces a negative number so close to zero that JS can't represent it?

0

What value results when a JavaScript math operation yields a positive number so close to zero that JS can't represent it?

What is an object refinement?

a . (dot) expression or [subscript] expression

0,-Infinity

What will the two alerts print out, at least in Firefox 17? (Format your answer like this: n,n) var x = -0; alert (x); alert (1/x);

push

What's an equivalent to the following statement? arX[ar.length] = 'newElement'; arX.p???('newElement');

underflow

What's called when a math operation results in a number that's too small for JS to represent?

NaN

What's the result of Math.sqrt(-3)?

a

What's the result of this operation: 100 / 0 ?. a) infinity b) NaN c) "Error: Division by zero"

What is identifier lookup

When you use a variable name in Javascript it begins a process called identifier lookup where it looks for something with the same name. It starts at whatever level of scope you are currently at and if not found it moves its way back up the "scope chain" until it resolves the name. If it cant find the identifier you get undefined. If you overwrite a value locally that was originally defined in a higher scope you effectively temporarily change the value of that variable while youre in that function scope. This is called shadowing.

How do you replace an element?

You call el.replaceChild( var_to_insert, el_it_comes_before );

What method do you call and what object do you call it on to create a element? How does it work?

You call the createElement method on the document object. It works by accepting a string, which is the element type, and then returns an element object of the corresponding type. This can then be appended.

How do you set an attribute on an element?

You call the setElement( ) method on a selected element.

What are the different ways of creating a new object?

You can create an object in several ways. #1 - you can write: var myObj = {}; and thus define it by an object literal. Then add to it with dot syntax. #2 - Alternatively, you can write a function and then call the new keyword in front of it: function Rabbit(adjective) { this.adjective = adjective; this.speak = function(line) { print("The ", this.adjective, " rabbit says '", line, "'"); }; } var killerRabbit = new Rabbit("killer"); killerRabbit.speak("GRAAAAAAAAAH!"); Using this method #2 is known as making a constructor for the object. The value of this will automatically point to the object created by using the new keyword. Method 2 also sets the correct prototype of the new object to its parent definition instead of pointing to the default new "Object".

bracket examples

[new RegExp("[abc]") or /[abc]/] [abc] - find any character between bracks [^abc] - find any char not in bracks [0-9] - find any digit 0-9 [A-Z] - find any char from uppercase A to uppercase Z [a-z] - find any char from lowercase a to lowercase z [A-z] - find any char from uppercase A to lowercase Z (red|blue|green) - find any of the alternations specified

What is the escape variable used for?

\ - delineate a special character & ANSI characters?

What is the string escape sequence to insert a double quote in JavaScript?

\"

What is the string escape sequence to insert a single quote in JavaScript?

\'

What is the string escape sequence to insert a backslash in JavaScript?

\\

What is the string escape sequence to insert a form feed in JavaScript?

\f

What is the string escape sequence to insert a tab in JavaScript?

\t

What is the escape sequence used to insert a Unicode character into a string in JavaScript?

\udddd //"dddd" is replaced by the hexadecimal value for the Unicode character

Variable?

a "basket" into which you can put info that can be taken out and interacted with or replaced

event handler

a "string" giving computation that runs when the timer goes off.

Properties

a characteristic or portion of a larger object. An example would be the status bar of the browser window denotes window.status.

increment

adding 1 to a value

variable

a quantity that can assume any of a set of values unless specified

function

a relation such that one thing is dependent on another

what is JavaScript?

a tool for web developers to programme HTML pages

variables

a. var myName = "Leng"; b. var myAge = 30; c. var isOdd = true;

concatenate

add

Arithmetic operator?

allow you to perform arithmetic within webpage

while if structure

allows a program to make a decision based on the truth or falsity of a condition

variable

always has a name that is used to fetch values can store values can be used as part of an expression can point to new values at any time two variables can point to the same value

step or step size

amount of change in each iteration

onLoad

an Event Handler that acts to trigger a function when the page loads. The command is placed in the BODY portion of the HTML document.

onSubmit

an Event Handler that is activated when the user clicks on a form submit button.

onSelect

an Event Handler that is activated when the user highlights text in a text or textarea form item.

are variables that can be set, just like you would set a loop counter or a string name in a program. background color

attributes

Escape symbol

backslash \

LOG2E is what?

base-2 logarithm of E approx (1.442)

It's good programming practice to declare all variables at the ____

beginning of a script

&&

binary operator means "and" result is only true if both values given are true greater precedence than ||

interact with two or more variables at a time.

binary operators; a * b; a / b

is a set of lines of code (or even a single line of code) that is meant to be executed together. { }

block

!!

can be used as a prefix operator, converting its operand to a boolean.

+

can be used as a prefix operator, converting its string operand to a number.

minus operator

can be used as both a binary and unary operator ex: -(10-2)

regexp quantifiers

can be used in conjunction with metacharacters

boolean

can have only two values, true or false.

shadowing

can't use global within function if you have local of same name

if statements use these to test for equalities or relationships between variables.

comparison operators == !=, <, >, <=, >=

Local variables are deleted when the function is ___, and global variables are deleted when you _____

completed, close the page.

pop ups

confirm(" text ") alert("text") prompt("text")

How do you display a confirmation?

confirm("Message Text Here");

confirm and prompt

confirm("confirm this"); prompt("yes or no");

If your browser supports debugging, you can use the ____ method to display JavaScript values in the browser.

console.log()

command that takes whatever is inside the parentheses and log it to the console below your code

console.log()

In debug mode, write the value of the variable c on the console.

console.log(c);

parameters

contained within a function definition, considered to be local variables, correspond with the arguments in the function call

join

creates a string with elements from array

strings

data type comprised of letters, numbers, spaces and characters, all in quotation marks

numbers

data type comprised of normal digits that are manipulated like normal numbers

booleans

data type comprised of true or false values

myFunction(argument1,argument2)

declare argument as variables when you declare function

!true

false

How do you code a for statement in JavaScript?

for (counter; condition; incrementor) {}

what is the syntax to write out a loopCounter variable between 0 to 2?

for (loopCounter = 0; loopCounter <= 2; loopCounter++) { document.write(loopCounter); }

prints all of the values of the object in the form

for (var propertyName in objectName) { console.log(propertyName + ": " + objectName[propertyName]); }

what are the two differnt kinds of loops in javascript?

for and while

Check if value stored in val is space or not a number.

if ((val.trim() == "") || isNaN(val))

example

if (12 / 4 === "Ari".length) { confirm("Will this run the first block?"); } else { confirm("Or the second block?"); }

Ray

if (4>100) {console.log("Helen");} else {console.log("Ray");}

Helen

if (5*2===10) { console.log("Helen");} else {console.log("Ray");}

Steve

if (8< 2) { console.log("Bob");} else {console.log("Steve");}

Bob

if (8>2) { console.log("Bob");} else {console.log("Steve");}

s the logical conditional AND operator. It evaluates two conditional statements until one evaluates to false. It then returns true if all conditional statements are true, and otherwise returns false.

if (a == 1 && b == 2) {...

is the logical conditional OR operator. It evaluates two conditional statements until one evaluates to true. It then returns true if any conditional statements are true, and otherwise returns false.

if (a == 1 || b == 2) {...

Check if the name of the source file of the HTML element, to which the variable image refers, contains the word 'bulbon'

if (image.src.match("bulbon"))

What would you use for validation of a number?

if (window.top.calcFactorial == null) throw "This page is not loaded within the correct frameset"; if (document.form1.txtNum1.value =="") throw "!Please enter a value before you calculate its factorial"; if (isNaN(document.form1.txtNum1.value)) throw "!Please enter a valid number"; if (document.form1.txtNum1.value <0) throw "!Please enter a positive number";

If Else Statement

if (xxx) { xxx; } else { xxx; }

If Else, Else Statement

if (xxx) { xxx; } if else { xxx; } else { xxx; }

If Statement

if (xxx) { xxx; }

if (condition) { code to be executed if true }

if Statement

What String object method is used return the position of the first instance of a specified search string, starting from the specified index?

indexOf(searchValue, startPosition); //If no startPosition is specified, the search begins from the start of the string

_variablename

indicates that its meant to be private and used with getters/setters get name(){} set name(){}

prototypal inheritance

inherit from prototype

bgColor

is a property of the object document. It denotes the background color of the HTML document.

Status

is a property of the object window. It denotes the status bar at the bottom of the browser screen.

Parent

is a property usually used with frames to denote a particular frame cell. When it is used outside of the frame format, it refers to the full browser window.

Semicolon

is a statement terminator. It says to the browser that this particular line of script has come to an end. If you don't use it, the browser will think the line continues and you'll probably get an error.

nodeList

is an array of elements per DOM specs

==

is less strictly equal to (opposite of Ruby)

!=

is not equal to

a%b binary

is the modulus operator (also called the remainder operator). a % b returns the remainder when a is divided by b.

a+b binary

is used for addition as well as string concatenation.

isNaN

isNaN(number); returns true or false

How do you test that a variable contains a valid number?

isNaN(varHere); //Returns true or false.

why should document.write() be avoided?

it can overwrite an entire HTML page. you can use document.getElementById("id").innterHTML= ...; instead

How do you get the customerName property from the CustomerBooking reference type

lets say that the instance is stored within a variable - var firstBooking - CustomerBooking (123, "Robert Smith", ..... Then it would be: firstBooking.getCustomerName()

player=["Larry","Moe","Curley","Shep","Chuck"];

literal array

global variables

live as long as the page, declared outside of functions

what are variables?

memory. names that you can store values with. to assign the name (variable) 'country' with the value 'Antarctica', you would write: var country = "Antarctica"; or you can use variables like so: x = 5; y = 4; z = x + y; so z would be equal to the value 9 and you would be able to refer to it in your code, like, say, if z was an amount of days

call-by-value

method of passing a copy of the arguments value to a function

call-by-reference

method of passing the arguments actual location in memory to a function

apply

method that invokes itself like call, but it takes arguments differently. It takes them as an array.

call

method that invokes itself with an extra argument added to the beginning of the method call

LN10 is what?

natural logarithm of 10 approx (2.302)

LN2 is what?

natural logarithm of 2 approx (0.693)

if you redeclare a variable, will it lose its value?

no

What happens if an arithmetic expression includes division by zero?

no error is raised; returns Infinity or -Infinity. EXCEPTION: 0/0= NaN (not-a-number)

conditions

no semicolons with ______

What are the simple types of Javascript?

numbers, strings, booleans, null and undefined.

How do you assign object properties?

obj["age"] = 17 or obj.age = 17

this

object similar to self in ruby

You can call an object method with the following syntax:

objectName.methodName();

object based programming what does this mean?

objects have properties & methods for example { var txt="Hello World!"; document.write(txt.length) } gives the property of length of txt and writes it to the doc which is 12.

Server side validation

occurs on server after data is submitted.

how do you convert a string to either a float or an integer?

parseInt(myString) and parseFloat(myString)

<noscript> element?

offers alternative content for users who have javascript disabled.

What are the events related to a text field? Which is of the most interest and why?

onchange, onselect, onkeydown, onkeypress and onkeyup. The onchnage event filres when the element loses focus and only if the value inside the text box is different

What are the events common to most controls?

onfocus //Fired when control receives focus onblur //Fired when control loses focus onclick //Fired when the control is clicked ondblclick //Fired when the control is double clicked onchange //Fired when the control's value is changed onselect //Fired when text is selected in a textbox or text area

else

only executes if the "if's" condition is false

alert

pops up an alert box with the given argument

duration

positive number in milliseconds saying when the timer should go off

=== and !==

precisely equal and not precisely equal

jQuery

prewritten javascript code used for websites

JavaScript does not have any ______ functions.

print or output

console.log

print to console

self executing anonymous functions

put parentheses around them

prompt("")

question pop-up

what are some things JavaScript can do?

react to events (like a mouse click) read and write HTML elements (like <p>) validate data (like form data) create cookies

keywords

recognized as a part of the language definition

What should precede the name of the function in an onsubmit event to validate a form?

return

What do you return if you want an onclick event not to go through

return true;

What do you put in your code to cancel the action associated with an event?

return value which is most often "false"

slice

returns a new array with a slice of the old array

Math.random

returns a number between zero and one

what are the rules and guidelines for naming variables?

rules: variables are case sensitive. y is not the same as Y. variables must begin with a letter or underscore ( '_' ) guidelines: short is good, but not always better. you do not want to write 'The_Name_of_the_Variable_That_Has_the_Time' each time you want the time, instead you could use 'currentTime' or 'time' if you only have one time variable. however, if you have five times, like different timezones, and you use a theme as vague as 'time_1', 'time_2', 'time_3', ..., you may forget what the variables mean

Object

something that exists such as the HTML Document, the browser window, or the date and time. An object can also be something that you create through a function.

event

something that happens at a given place and time

sort() for numbers?

sorting by numbers is different, using a sort function is necessary. function sortNumber(a,b) { return b-a;// for descending return a-b;// for ascending }

method in literal notation

speak: function(feeling) { console.log("Hello, I'm feeling " + feeling); }

$.data()

store arbitrary data associated with the matched elements or return the value at the named data store for the first element in the set of matched elements. $.data( key, value ) jQuery.removeData()

three basic data types

string, number & boolean

What String object method is used to return a new string that contains part of the original string from the specified start position and up to but not including the specified stop index?

substring(startIndex, stopIndex); //stopIndex is optional, if it is not specified, then it will go until the end of the string

What is the format for a switch statement in JavaScript?

switch (inputVar) { case "caseSwitch1": //Operations here //No break so it cascades to caseSwitch2. case "caseSwitch2": //Operations here break; //Break so it will not continue to cascade down. }

Outline a switch statement if 1 write "Too low!", otherwise write "This is fine".

switch (secretNumber) { case 1: document.write("Too low!"); break; default: document.write("This is fine"); break; }

switch(n) { case 1: execute code block 1 break; case 2: execute code block 2 break; default: code to be executed if n is different from case 1 and 2 }

switch statement

switch statement syntax?

switch(variable) { case 1; code break; case "example"; code break default; code }

booleans only non-primitve is what?

toString() boolean.toString()

What Date object method is used to return a string containing the date and time?

toString();

What Number object method is used to return a string with a given number base?

toString(base); //Bases can range from 2 to 36

What Date object method is used to return a string containing the time?

toTimeString();

how can you target an HTML element using JavaScript?

use document.getElementById(id); the id should be in quotations if it is a string; if it is a variable, it should only be in parentheses

index

used to access the various elements in an array

< and >

used to compare numbers and strings strings are compared alphabetically, uppercase letters are less than lowercase ones, and symbols are included (!, @, etc.) based on Unicode Standard which gives a number to virtually every character possible compares number of characters in string from left to right

\b meta character does what?

used to find a match at the beginning or end of a word (if none null) x="hello world" y=/\bworld/g document.write(x.match(y))--> world

\S meta character does what?

used to find a non-whitespace character x="hello world" y=/\S/g document.write(x.match(y))-->h,e,l,l,o,w,o,r,l,d

backslash

used to include characters without ending the string (ex: quotation marks) \n = new line \t = tab \\ = just one backslash

what are regexp modifiers?

used to perform case-insensitive and global searches

Switch Statements

used to select one block of code from many depending on a situation.

How do you get or change an elements content?

using the innerHtml property.

if isNaN(x) { alert("not numeric")};

validate input

onsubmit should be used for what and where?

validating form fields ex. <form action="blah.asp" methond="post" onsubmit="return checkForm()">

parameters

values that function will compute on

how is regexp defined?

var patt = new RegExp(pattern,modifiers) or var patt = /pattern/modifiers

JavaScript Objects

var person={firstname:"John"};

for... in statement syntax?

var person={fname:"john",lname:"doe",age:"25"}; var x; for (x in person) { document.write(person[x]+" "); } ------- loops through all variables attached to person;

general method

var setAge = function(newAge){ this.age = newAge; };

How do you concatenate multiple parts into a string?

var stringVar = "part 1:" + "part 2";

How do you assign the value from a prompt to a string?

var stringVar = prompt("Text Here");

Get the value of input field with id="numb" and store it in the variable var.

var val = document.getElementById("numb").value;

Guard (&&)

var value = p && p.name; /* The name value will only be retrieved from p if p has a value, avoiding an error. */

break

when a loop does not have to go to completion, the break jumps out of the loop and continues after it

arguments

when invoking a function, name function followed by the arguments in parenthesis

how will JavaScript execute by default?

when the page loads

undefined

when you ask for the value of an empty place

parseFloat

when you need to convert a string-ified hex number (or other base besides base 10) to a float, don't use Number(). Use ??? instead.

when should you use an external javascript?

when you want to run the same JavaScript on several pages, without having to write the same script on every page.

when should scripts be placed in the body?

when you want your script to be placed inside a function, or if your script should write page conten.

statement uses a pretest, where a condition is tested before the loop is run. If the condition is false, the code inside the loop never gets executed.

while

Write a while statement that beaks out of the look when the user enters a -1

while ( (timesTable = prompt("Enter the times table",-1)) != -1) { if (timesTable == -1) { break; } }

var message="Hello World!"; var x=message.length;

x returns 12.

Attach Text To Element

xxx.appendChild(xxx);

JavaScript programs are written using the ____ character set.

Unicode

How can you break a string literal across multiple lines? "aw;e fimawe;ifomae;iam im ‚Ä® e;imfe;iof mawfimawe;fi mawe;fi ma;i a; eimfa;oei maw;oeif mawe;oi fmaw;o im?"

Use a backslash (\)! If a new line character should be included, use "\n" "aw;e fimawe;ifomae;iam im \‚Ä® e;imfe;iof mawfimawe;fi mawe;fi ma;i\ a; eimfa;oei maw;oeif mawe;oi fmaw;o im?"

if a variable is not a function and does not have var then it is?

a global variable

var later= new Date(2015, 1, 9, 5, 31, 24) Access… a.) year b.) month c.) date d.) day of the week e.) hours, UTC time f.) hours, local time

a.) later.getFullYear() //2015 b.) later.getMonth() //1 (february) c.) later.getDate() //9 d.) later.getDay() //1 (0=sunday) e.) later.getUTCHours() //13 (in UTC time) f.) later.getHours //5 (5am local time)

var s ="hello, world" Give: a.) the third character b.) "ello" c.) position of the first letter "l" d.) position of the last letter "l" e.) position of the first "o" at or after the third position f.) an array of the string split at ", "

a.) s.charAt(2) or s[2] //"l" b.) s.substring(1,5) // "ello" c.) s.indexOf("l") // 2 d.) s.lastIndexOf("l") //10 e.) s.indexOf("o",3) //4 f.) s.split(", ") // ["hello","world"]

Describe implicit type conversions with JS operators. a.) convert x to string b.) convert x to number c.) convert x to boolean

a.) x + "" b.) +x or x-0 c.) !!x

var x = 12345.789 a.) Convert x to : 12345.7 b.) Convert x to 1.2e4 c.) Convert x to 1.235e4

a.) x.toFixed(1) //# digits after decimal b.) x.toExponential(1) //# digits after decimal c.) x.toPrecision(4) //#significant digits

types of strings object properties

constructor- returns the function that created the objects prototype. length- returns the length of characters of a string. prototype-allows you to add properties and methods to an object.

toLowerCase() method does what?

converts a string to lowercase letters e.x. string.toLowerCase() x="BLAH" document.write(x.toLowerCase())---->blah

javascript syntax for a (limited loop based on specifications) syntax?

for(variable=startvalue;variable<=endvalue;variable=variable+increment) { code to be run until loop is complete. }

else if conditional syntax?

if(condition) { code } else if(condition) { code }

What is a FUNCTION?

named and parametrized block of JavaScript code that you define once, and can then invoke over and over again

HTML DOM mouse events?

onclick ondblclick mousedown mousemove mouseover mouseout mouseup

What happens if an arithmetic expression OVERFLOWS?

overflow: value > larger representable # no error raised; Infinity or -Infinity is set as the value

confirm box syntax?

r=confirm("press a button") if(r==true) { alert('you pressed ok!'); } else { alert('you pressed cancel'); }

substr() does what?

same as substring except uses length as opposed to a stop number e.x. string.substr(start,length) x="hello world" document.write(x.substr(0,4))--->hello

search() method does what?

searches for a match between a regular expression and the string and returns the position e.x. string.search(regexp) x="hello world" document.write(x.search("wo"))--->7

match() method does?

searches for a match between the regexp and a string and returns the matchs e.x. string.match(regexp) x="hello world" document.write(x.match("hello"))-->hello

What is a STATEMENT?

statement = sentence of JavaScript that alters the program (but doesn't have a value), ends with a semicolon (e.g. var x=1; , if(x){ x=1 };)

How can you get an array of the matching values of a RegExp pattern in a string?

text.match(pattern)

How can you replace the values in a string that match with a RegExp pattern with another value?

text.replace(pattern, "thing to be replaced with")

How can you search for a RegExp pattern in a string?

text.search(RegExp_pattern)

What is the result of: 0 === -0

true

var x = 0.3 - 0.2; var y = 0.2-0.1; --- What is the result of: x == y;

x==y //false x==0.1 //false y==0.1 //true --- rounding error! approximation of 0.1 isn't exact. Computed values are adequate for almost any purpose, but the problem arises when attempting to compare for equality.

numerical comparison operators?

x==y [x is equal to y] x===y [x is exactly equal to y] != [not equal to] > [greater than] < [less than] >= [greater than or equal to] <= [less than or equal to]

How can you concatenate strings?

"string 1"+"string2"

making a global (multiple) case insensitive search?

/content goes here/g; var x = /money/g

javascript starts counting on what?

0

How can you do arithmetic in JavaScript?

ARITHMETIC OPERATORS: +, -, *, /, % (modulo/remainder) More complex mathematical operations can be done via properties of the Math object.

var o = {x:1} var p = {x:1} o === p //what is the result?

False. Objects are compared by reference ("reference types") not value.

What is an IDENTIFIER?

Identifiers are used to name variables and functions and to provide labels for certain loops in JS code. Must begin with a letter, an underscore ( _ ), or a doller sign ($). E.g. i, my_variable_name, v13

Strings are MUTABLE/IMMUTABLE. (Choose one) What does this mean?

Methods done on strings return new strings, not modify the string on which they were invoked (e.g. replace() and toUpperCase())

How can you convert strings to numbers?

Number() parses as integer/floating point, but does not allow trailing characters/whitespace parseInt() parses only integers, skipping leading whitespace/other characters. parseFloat() parses both integers and floating characters

How are JavaScript types categorized?

PRIMITIVE TYPES: numbers, strings, booleans, null, undefined OBJECT TYPES: global object, array, function MUTABLE TYPE = value can change (objects and arrays) IMMUTABLE: value cannot change (numbers, booleans, null, undefined)

logical operators?

&& [and] || [or] ! [not]

how to make a case sensitive (single) search?

("w3schools") - case sensitive (/w3schools/) - case insensitive /content/;

javascript comment syntax?

/* */ for multiple lines // for a single line

var a = [] var b = a b[0] = 1 What is the value of: 1.) a[0] 2.) a ===b

1.) 1 2.) true. b refers to the same object as a.

Strings, numbers, and Booleans have properties and methods. Why?

A temporary Wrapper object (via new String() etc) is created when a property/method is accessed, then immediately discarded.

JavaScript DOES/DOESN'T make a distinction between integer values and floating point values.

DOESN'T. All numbers=floating-point values.

How can you convert numbers to strings?

Methods to convert to strings with control over the #decimal places/significant digits. 1.) toFixed(x) 2.)toExponential(x) 3.) toPrecision(x)

Reg Exps are [A FUNDAMENTAL TYPE] / [OBJECT]

OBJECT. Created by constructor RegExp(). Have a literal syntax. Regular expression literal = text between a pair of slashes (e.g. /^HTML/)

Explain what it means that JavaScript uses LEXICAL SCOPING.

Variable scope is based on lexical structure. Variables declared outside of a function are global variables and visible everywhere, whereas variables declared inside a function have function scope and are visible only to code inside the function.

Briefly explain object oriented programming

You can think of an object as being described by characteristics (properties) and its abilities/functions (methods). In object-oriented programming (OOP), objects are acting on other objects with their predefined methods.

special text insertions?

\' single quote \" double quote \n new line \r carriage return \t tab \b backspace \f form feed

What is a LITERAL?

a data value that appears directly in the program (e.g. 12, "hello world", true)

Is javascript case sensitive?

yes!

s="hello, world"; What is the result of: a.) s[0]; b.) s[s.length-1];

a.) h b.) d *strings can be treated like read-only arrays

toUpperCase() method does what?

converts a string to uppercase letters e.x. string.toUpperCase() x="blah" document.write(x.toUpperCase())---->BLAH

replace() method does what?

searches for a regexp or substring and replaces it with a new string. e.x. string.replace(regexp/substr,newstring) x="hello world" document.write(x.replace("hello","goodbye"))-->goodye world

numbers + strings =? 5+"5" = ?

strings 55

What does an operator do?

Act on values (the operands) to produce a new value (e.g. +, ==, &&)

The JavaScript variable hello_world is the same as the variable Hello_World. (True/False)

False; JavaScript is a case-sensitive language.

What is the result of: if(""){ console.log("true"); } else { console.log("false"); }

false

the break and continue statement?

if(i==3) { break; } breaks loop if(i==3) { continue; } breaks loop and restarts at next value;

concat() method does?

joins 2 or more strings then returns a copy. e.x. string.concat(string2) x="hello world " y="goodbye world" document.write(x.concat(y))--> hello world goodbye world

lastIndexOf() method does what?

returns the position of the last occurence of a specified value in a string. e.x. string.lastIndexOf(regexp,start) x="hello world" document.write(x.lastIndexOf("wo",0))--->7

valueOf() method does what?

returns the primitive value of a string. e.x. string.valueOf() x= "Hi!" document.write(x.valueOf())----> Hi!

charCodeAt() method does?

returns the unicode of the character at a specific index in a string. e.x. string.charCodeAt(index) x="hello world" document.write(x.charCodeAt(0))--->72

What happens if an arithmetic expression UNDERFLOWS?

underflow: value closer to zero than smallest representable # no error raised; returns 0 or negative zero (approaches from negative number)

Create a Date object for June 28, 2014 at 5:03:30 pm local time

var beforetime = new Date(2014, 5, 28, 17, 3, 30)

can variables include other variables?

yes


संबंधित स्टडी सेट्स

Spanish (to talk abt what you and others are like

View Set

human anatomy homework chapter 8

View Set

Ch. 29 -Trauma to the Head, Neck, and Spine

View Set

CP- Drug Therapy for Diabetes Mellitus

View Set

Conduction, Convection or Radiation?

View Set