IES: JS-deck 9 Flashcards
1
Q
HTML outerWidth
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- property returns outer width of browser window, including all interface elements (like toolbars/scrollbars)
- read only
- Syntax
window.outerWidth
orouterWidth
- Return Value
Browser window width, all interface elements, in pixels
2
Q
HTML packages
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- In web development context, collection of HTML files, often grouped with related assets like CSS and JavaScript
- easily imported or reusable component in a larger website
- Acting as pre-built module with specific functionality/design
- Example
Product card package:
1.product-card.html
: card structure & image, title, price, etc. placeholders
2.product-card-styles.css
: card styles (layout, colors, fonts)
3
Q
HTML pageXOffset
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- read-only property: equal to
scrollX
- returns pixels doc scrolled from upper left window corner
Syntaxwindow.pageXOffset
orpageXOffset
Example
~~~
window.scrollBy(100, 100);
alert(window.pageXOffset + window.pageYOffset);
(scrolls the content by 100 pixels, and alerts the pageXOffset and pageYOffset)
~~~
4
Q
HTML pageYOffset
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- read-only property: equal to
scrollY
- returns pixels doc scrolled from upper left window corner
- Syntax
1.window.pageYOffset
or
2.pageYOffset
- Example
~~~
// Get the navbar
const navbar = document.getElementById(“navbar”);
// Get the offset position of the navbar
const sticky = navbar.offsetTop;
// Add the sticky class to the navbar when you reach its scroll position. Remove the sticky class when you leave the scroll position.
function myFunction() {
if (window.pageYOffset >= sticky) {
navbar.classList.add(“sticky”)
} else {
navbar.classList.remove(“sticky”);
}
}
~~~
(Create a sticky navigation bar)
5
Q
HTML parent
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- parent is the element which contains another element
- children are the contained elements.
- A child element can also have nested elements inside it, making it a parent element to its nested elements.
- Very often children behavior/appearance influenced by their parent settings.
6
Q
HTML parseFloat
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- method parses a value as a string and returns first number
- first character can’t convert,
NaN
returned - Only first number found returned
- Syntax
parseFloat(value)
- Example
~~~
parseFloat(“40.00”);
parseFloat(“ 40 “);
parseFloat(“40 years”);
parseFloat(“40H”)
parseFloat(“H40”);
~~~
(Parse different values)
7
Q
HTML parseInt
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- method parses a value as a string & returns first integer
- A radix parameter specifies number system:
2 = binary, 8 = octal, 10 = decimal, 16 = hexadecimal. - radix is omitted, JS assumes radix 10: value begins “0x”, ONJS assumes radix 16.
- Older JS versions used octal (radix 8) values begin with “0”: From JS5 (2009), default is decimal (radix 10).
- first character can’t convert, NaN is returned
- Leading & and trailing spaces ignored.
- Only first integer found returned.
8
Q
HTML password
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
-
<input>
type attribute: defines a password field - sensitive info should always be served over HTTPS
- always add
<label>
for best accessibility practices - Syntax
<input type="password">
- Example
~~~
<label>Password:</label>
<input></input>
~~~
9
Q
HTML pkcs11
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- Cryptography: secure info & comm techniques derived from algorithms to transform messages in ways hard to decipher
- cryptographic token interface standard that defines an API, called Cryptoki, for accessing cryptographic devices
- represents cryptographic devices using tokens (digital representations of interest (percent of ownership) in an asset): Any device or token can perform cryptographic operations using same independent command set.
10
Q
HTML plugin
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- computer programs extending standard browser function
- MOST BROWSERS DON’T BEAR JAVA APPLETS & PLUG-INS
11
Q
HTML prompt
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- method displaying dialog box prompting for input
- returns input value if “OK” clicked, otherwise returns null
- Syntax
prompt(text, defaultText)
- Example
~~~
let text;
let favDrink = prompt(“What’s your favorite cocktail drink?”);
switch(favDrink) {
case “Coca-Cola”:
text = “Excellent choice! Coca-Cola is good for your soul.”;
break;
case “Pepsi”:
text = “Pepsi is my favorite too!”;
break;
case “Sprite”:
text = “Really? Are you sure the Sprite is your favorite?”;
break;
default:
text = “I have never heard of that one!”;
}
~~~
12
Q
HTML propertyIsEnum
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- (C, C++, C#, Java) special type of constants (unchangeable values)
- create enum: use enum keyword, followed by enum name
- enum has attributes and methods
- (couldn’t find “propertyIsEnum”)
- Example
~~~
enum Months
{
January, // 0
February, // 1
March, // 2
April, // 3
May, // 4
June, // 5
July // 6
}
static void Main(string[] args)
{
int myNum = (int) Months.April;
Console.WriteLine(myNum);
}
~~~ - (Output is 3)
13
Q
HTML radio
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
-
<input type="radio">
defines a radio button. - normally presented in groups (related set options)
- Only one in a group can be selected at the same time.
- must share same name attribute to be treated as group
- selecting any button auto deselects any other in same group
- have as many groups: each page group must have own name
- Always add the
<label>
tag for best accessibility practices! - Syntax
<input type="radio">
- Example
~~~
<input></input>
<label>HTML</label><br></br>
<input></input>
<label>CSS</label><br></br>
<input></input>
<label>JavaScript</label>
~~~ - (Allow selection of only one of limited number of choices)
14
Q
HTML reset
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
-
<input type="reset">
: resets form values to initial values - Syntax
<input type="reset">
- Example
<input type="reset">
- (Defines a reset button)
15
Q
HTML screenX
A
- HTML Name, Window Object, or Property
- JS significant: avoid for variable/function names
- property returns x (horizontal) window coordinate relative to screen (in pixels)
- Syntax
window.screenX
orscreenX
- Example
~~~
const myWin = window.open(“”, “”, “width=200,height=100”);
let x = myWin.screenX;
let y = myWin.screenY;
~~~ - (Opens new window; returns coordinates)