Week 5 Flashcards
When JavaScript manipulates a page or responds to user actions, what is it called?
Event Handling
JavaScript can…
Dynamically update _______ (CKE)
Manipulate ____ and ___
Manipulate and validate ____
Content, HTML and CSS, Data
As a developer
JavaScript cannot…
Write data permanently to an existing file
Access files on the server
Get data from the server database
Handle file uploads
JavaScript was introduced by NetScape in ____
JavaScripts biggest update was in 2015 when ___ was released, the ___ version
1996, ES6, 6th
Is JavaScript interpreted or compiled?
Interpreted
JavaScript’s key construct is the ________
function
3 ways to add JavaScript to an HTML page. Which way is recommended?
Embed, Inline, Link
Link is recommended
T/F - To embed a script with JavaScript, just add the code as part of a script element
True
To link a JavaScript file, just like a CSS file, where does the link go?
In the HTML pages head
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<button> Click Me! </button>
</body>
</html>
Will myFunction() link to the JavaScript function?
Yes
How do comments in JavaScript compare to Java?
They are identical
alert()
Display content with a pop up box
prompt()
DIsplays a message and an input field within a modal window
confirm()
Displays a question in a modal window with ok and cancel buttons
console.log
Display content in the browsers JavaScript console
document.write()
outputs the content (as markup or code) directly to the HTML document
What does markup mean?
Markup is the series of characters, symbols, and language that organizes and defines how the content looks, It is the code.
T/F - Each browsers console tab includes a text that you can use to enter your expressions or statements
True
T/F - You can execute multiple statements in the console by separating each statement with a semicolon
True
3 ways JavaScript code executes:
- Auto, when the page loads
- When your script calls a function
- In response to some event, such as the user clicking a button
JavaScript variables are dynamically _____, declared with the ___ or ___ keyword and are ____ _________
typed, let or var keyword, case senstiive
What does typeof do in JavaScript?
Figures out a given variables type
What is the default value and type of a declared but uninitialized varaible?
Undefined and undefined.
Do we use camelCasing for JavaScript?
yes
T/F - In JavaScript, a variable can be declared after it has been used
True, it’s called hoisting
Explain hoisting in JavaScript
It’s JS’s default behavior of moving declarataions to the top
Explain the difference between “var” and “let” during these 3 scenarios
Scope
Re-declaration
Hoisting
Scope
* var declarations are function-scoped.
* let variables are block-scoped.
Re-declaration
* var variables can be updated and re-declared within the scope.
* let variables can be updated but not re-declared.
Hoisting
* var variables are hoisted with an initial value undefined.
* let variables are not hoisted with an initial value
In JavaScript the “numbers” datatype represents ________ and ________-_____ numbers
integers and floating point
An “object” in JavaScript includes ________ and ______
functions and arrays
T/F - In JavaScript, strings can only be double quotes
False, they can be both double and single quotes
What happens in each of these variable cases?
1. let a = “10”; let b = 20; console.log(a+b)
2. let a = “10”; let b = 20; console.log(+a+b)
3. let a = “10”; let b = 10; console.log(a-b)
4. let a = “10”; let b = true; console.log(a-b)
5. let a = “hello”; let b = “world”; console.log(a-b)
- 1020
- 30 - the 10 gets converted to a int the by unary operator (+)
- 0 (converted to int by the -)
- 9 (true = 1 when converted)
- NaN
Name the string PROPERTY that can be used to see how long a string is
stringName.
stringName.length
When using the Boolean() function, what are the values that will return false? what will return true?
False: 0, 0.0, NaN, empty string “”, null, and undefined
True: anything else
JavaScript operators: +, -, /, *,… 3 more
% modulo division
++ increment
– decrement
JavaScript Assignment Operators:
a += b
a *= b
a %= b
What do these do?
a = a+b
a = a*b
a = a%b
T/F - else-if behaves the same way as if-else in Java
True
All loops in JavaScript must consist of 3 things, what are they?
Incrementor
Conditional expression
Logic to increase the incrementor