IES: JS-deck 1 Flashcards
1
Q
JS background & history
A
- JavaScript
- Object-based scripting language
- the language interpreter is embedded inside web browser software such as:
1. Google Chrome
2. Microsoft Edge
3. Firefox
4. Opera
5. Safari - JavaScript cannot read or write files for security (exception: cookies (store minimal data))
- JS also named:
1. “LiveScript” (initial name)
2. “JavaScript” (possibly due to the popularity of Sun Microsystem’s Java(little resemblance)) (name widely used)
3. “ECMAScript” (June, 1997: Ecma international standards organization standardization) (name not widely used)
4. Not “JScript” (different language altogether)
2
Q
Brendan Eich
A
- created JavaScript at Netscape
- First introduced JS in December of 1995
- Co-founded Mozilla project
- Helped launch Firefox
3
Q
JSON
A
- JavaScript Object Notation
*
4
Q
IES JavaScript examples-3 key ingredients
A
- Language basics-illustrates language mechanics:
- Syntax
- Keywords
- Operators
- Structure
- Built-in objects
- Web page functionality
* Illustrates the use of the browser’s DOM to provide user interaction - Web applications
* Illustrates responsive web-based apps
* Illustrates JSON techniques
5
Q
JS in HTML doc
A
- included directly: must be between
<script>
/</script>
- Doc can include multiple scripts
- Scripts may be in head or body of document
- (recommended) place scripts at the body end
- Place immediately before the
</body>
: so browser renders webpage before script interpretation
6
Q
JS don’ts
A
-
type="text/JavaScript"
in a<script>
is NO LONGER NECESSARY as JS is HTML default scripting language - DO NOT Include
<script>
and</script>
in an external JS file
7
Q
JS external files
A
- Written in plain text files given a
.js
extension - Allows several different pages to call upon same script
- To include in HTML doc, file name is assigned to
src
of the<script>
- Script source can be placed in doc head or body
- browser will treat script as if written directly where script source is placed
- can make code maintenance easier
8
Q
locating .js file to assign as script source
A
- Requires script file be in same folder (directory) as HTML doc
Ex.<script src="external_script.js"> </script>
- script in adjacent folder: Assign relative path address of file
Ex.<script src="js/external_script.js"> </script>
- Script located elsewhere?: assign absolute path file address
Ex.<script src="https://www.example.com/js/external_script.js"> </script>
9
Q
disable JS
A
- some content will only appear if JS is disabled in the web browser
- JS is disabled by including a
<noscript>
in HTML doc body
Ex.<noscript>JavaScript is Not Enabled!</noscript>
10
Q
document.getElementbyId( ‘message’ ).innerText = ‘Hello World!’
A
- JS displays output dynamically writing content into HTML
- element identified by id attribute
- innerText specifies text
11
Q
window.alert( ‘Hello World!’ )
A
- JS displays content in a pop-up dialog box
- Calls the alert() method
- Of the window object
-
Displays content specified within the parentheses in a dialog box
Ex. (This page says
Hello World!
OK button (bottom, right-hand corner))
12
Q
” . “
A
- operator
- Describes properties or methods of an object
- “dot notation”
13
Q
console
A
- provide helpful messages when code error occurs
- great for debugging code
- All leading browsers have JS console within developer tools
- Developer Tools feature-typically accessed:
F12
- Displays output as well as HTML Doc name and line number of source JS code
14
Q
console.log( ‘Hello World!’ )
A
- displays output in browser’s JS console
- (when developing in JS and learning the language, displaying here is initially better)
- Calls the log() method
- Of the console object
- Displays content within () in console window
15
Q
document.write()
A
- Use is generally considered bad practice
- method that replaces the entire header and body of the web page