IES: JS-deck 11 Flashcards

1
Q

HTML onmouseup

A
  • HTML event attribute
  • JS significant: avoid for variable/function names
  • occurs when mouse button released over element
  • Syntax
    (HTML) <element onmouseup="myScript">
    (JS) object.onmouseup = function(){myScript};
    (JS addEventListener() method) object.addEventListener("mouseup", myScript);
  • Example
    <p onmouseup="mouseUp()">Click the text!</p>
  • (Call a function when releasing a mouse button over a paragraph)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

HTML onmouseover

A
  • HTML event attribute
  • JS significant: avoid for variable/function names
  • occurs when mouse pointer enters an element
  • often used with onmouseout event
  • similar to onmouseenter event: difference is onmouseenter event doesn’t bubble (relay info and influence up doc hierarchy).
  • Syntax
    (HTML) <element onmouseover="myScript">
    (JS) object.onmouseover = function(){myScript};
    (JS addEventListener() method) object.addEventListener(“mouseover”, myScript);
  • Example
    <img onmouseover="bigImg(this)" src="smiley.gif" alt="Smiley">
  • (Calls a function when moving the mouse pointer onto an image)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

HTML onmouseout

A
  • HTML event attribute
  • JS significant: avoid for variable/function names
  • occurs when mouse pointer moves out of element.
  • often used together with onmouseover event
  • onmouseout event similar to onmouseleave: difference is onmouseleave doesn’t bubble (does not relay info and influence up the document hierarchy).
  • Syntax
    (HTML) <element onmouseout="myScript">
    (JS) object.onmouseout = function(){myScript};
    (JS addEventListener() method) object.addEventListener("mouseout", myScript);
  • Example
    ~~~

<div>
<p>I will demonstrate onmouseout!</p>
</div>

~~~
* (example demonstrates the onmouseout event)

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

HTML onmousemove

A
  • HTML event attribute
  • JS significant: avoid for variable/function names
  • occurs when the pointer moves over an element
  • Syntax
    (HTML) <element onmousemove="myScript">
    (JS) object.onmousemove = function(){myScript};
    (JS addEventListener() method) object.addEventListener("mousemove", myScript);
  • Example
    <div onmousemove="myFunction()">Move the cursor over me</div>
  • (Call a function when moving the mouse pointer over a <div> element)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

HTML onchange

A
  • HTML event attribute
  • JS significant: avoid for variable/function names
  • occurs when HTML element value changes.
  • similar to oninput event: difference is oninput occurs immediately after element value changed
  • onchange occurs when element loses focus, after the content has been changed.
  • other difference- onchange works on <select> elements
  • Syntax
    (HTML) <element onchange="myScript">
    (JS) object.onchange = function(){myScript};
    (JS addEventListener() method) object.addEventListener("change", myScript);
  • Example
    <input type="text" onchange="myFunction()">
  • (Calls a function when input field content changes)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

HTML onreset

A
  • HTML event attribute
  • JS significant: avoid for variable/function names
  • occurs when a form is reset
  • Syntax
    (HTML) <element onreset="myScript">
    (JS) object.onreset = function(){myScript};
    (JS addEventListener() method) object.addEventListener("reset", myScript);
  • Example
    ~~~

<form>
Enter name: <input></input>
<input></input>
</form>

~~~
* (Call a function when a form is reset)

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

HTML onsubmit

A
  • HTML event attribute
  • JS significant: avoid for variable/function names
  • occurs when a form is submitted
  • Syntax
    (HTML) <element onsubmit="myScript">
    (JS) object.onsubmit = function(){myScript};
    (JS addEventListener() method) object.addEventListener("submit", myScript);
  • Example
    ~~~

<form>
Enter name: <input></input>
<input></input>
</form>

~~~
* (Calls a function when a form is submitted)

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

variable

A
  • a container
  • Common to every scripting and programming language
  • data can be stored here and retrieved later
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

“strongly typed” variables

A
  • in most programming languages
  • must declare the particular data type they may contain
  • JS variables are not in this category
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

“loosely typed” variables

A
  • JS variables are in this category
  • may contain any type of data
  • much easier to use than “strongly typed” variables
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

variable name

A
  • an alias for the value it contains
  • Used in script
  • references its stored value
  • to ease script understanding, choose meaningful ones
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

variable data types, data descriptions, and data examples

A
  1. string
    * a string of text characters
    * Ex. ‘Hello World!’
  2. number
    * an integer or floating-point number
    * Ex. 3.142
  3. Boolean
    * A true (1) or false (0) value
    * Ex. true
  4. object
    * a user-defined or built-in object
    * Ex. console
  5. function symbol
    * a user-defined function, a built-in function, or an object method
    * Ex. log( )
  6. symbol
    * a unique property identifier
    * Ex. Symbol( )
  7. null
    * absolutely nothing (not even zero)
    * Ex. null
  8. undefined
    * a non-configured property
    * Ex. undefined
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

declaring JS variables

A
  • begin with keywords:
    1. “let”-can be reassigned new values as script proceeds
  • this declaration may create a variable with a value to be assigned later
  • this declaration may include an instant value assignation (“initialized”)
  • subsequent assignation of different data types later in the script can be made
    2. “const”- (constant) does not allow values to be reassigned
    3. “var”- (best avoided-deprecated?) Does not prevent same variable being declared again in the same context
  • current variable type can be revealed using “typeof.”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The concatenation “ + “ operator

A
  • used in these examples to output a combined text string
  • “typeof” keyword reveals current variable type
  • Ex.
    console.log( ‘firstName: ‘ + typeof firstName )
    console.log( ‘valueOfPi: ‘ + valueOfPi )
    console.log( ‘isValid: ‘ + isValid )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

known error in JS regarding null

A
  • variable assigned a null value is described as an object type
  • (variable with a null value should be described as a null type?)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
A