Chapter 8 : Introduction to JavaScript Flashcards
Who invented JavaScript?
- Brendan Eich ( 1995 )
- Java
- General Purpose Programming Language
JavaScript - Used on websites to make them animated and interactive
- General Purpose Programming Language
List out 5 examples that JavaScript can do?
- Change HTML content
- Change HTML attributes
- Change HTML styles ( CSS )
- Hide HTML elements
- Show HTML elements
What HTML tag is used for JavaScript , CSS?
<script> </script>
- <style></style>
When does the JavaScript function called?
- Executed when the JavaScript function called
- A function can be called when an event occurs, like when the user clicks a button
What is the file extension for JavaScript files?
- .js
How to link external JavaScript ?
- Can be placed inside < head > or < body >
What is the advantages of JavaScript? ( 3 )
- Separates HTML and code
- Makes HTML and JavaScript easier to read and maintain
- Cached JavaScript files can speed up page loads
How to add several script files?
<scri[t src=”myScript1.js”>
</script>
List out 4 ways that JavaScript can display data
- window.alert() - Alert Box
- document.write() - Write into HTML Output
- innerHTML - Write into HTML element
- console.log() - Write into Browser Console
How to show window alert of 5 + 6 ?
<!DOCTYPE html>
<html>
<body>
<script> window.alert(5+6); </script>
</body>
</html>
How to use document.write() to show 5 + 6 ?
<!DOCTYPE html>
<html>
<body>
<button>Try It</button>
</body>
</html>
- Write the answer 11 where the code is placed
How to display new paragraph for 5 + 6 using JavaScript?
<!DOCTYPE html>
<html>
<body>
<p></p>
<script> **document.getElementById("demo").innerHTML = "<h2>5 + 6</h2>";** </script>
</body>
</html>
How to write the total amount for 5 + 6 into browser console?
<!DOCTYPE html>
<html>
<body>
<script> console.log(5+6) <script> </body> </html> </script></body></html>
What is JavaScript Syntax?
- JavaScript syntax is the set of rules of how JavaScript programs are constructed
List out 5 statements that JavaScript are composed of
- Values
- Operators
- Expressions
- Keywords
- Comments
- Statements are being executed one by one, in the same order as they are written
What are program instructions called?
- Statements
What is JavaScript statement seperated by?
- Semicolons
List out JavaScript Arithmetic Operators ( 7 )
- /
- %
- ++
- –
List out JavaScript assignment operator ( 6 )
- =
- +=
- -=
- *= ( x = x * y )
- /=
- %=
List out JavaScript Comparison Operators ( 9 )
- ==
- === ( Equal value and equal type )
- !=
- !== ( Not equal value and not equal type )
- >
- <
- > =
- <=
- ?
List out 2 JavaScript Type Operators
- typeof
- Returns the type of a variable
- instanceof
- Returns true if an object is an instance of an object type
What are JavaScript comments being used to? ( 2 )
- Explain JavaScript code, and to make it more readable
- Prevent execution, when testing alternative code
List out :
1. Single Line Comments
2. Multiline Comments
- //
- Starts with /* , End with */
What are variables used for?
- Containers for storing data values