What is JavaScript?
- Responsible for Interaction
- Runs on client
What is it good for?
- DOM Management
- Event Handling
How do you use it?
- Inline,
<script>
,<script src="">
- Inline w/event attributes
- Inefficient practice
Try it
Using the <script>
tag
- Better than inline, but maintainable
- Code executes when script read
Try It
As an external document
- Using
<script src=""></script>
<script>
position important
JavaScript Variables
- Losely typed
- Basic types
1 | var myName = 'Ray'; |
JavaScript Lists
- 0 Indexed
1 | var myList = ['Ray', 'Fred', 'Bonnie']; |
Try it
JavaScript Objects
- Complex data type
- Holds any var type
1 | var info = { |
Try it
Document Object Model (DOM)
- Page structure
- Add, delete & modify
querySelector()
querySelectorAll()
Try it
Events
- Things that happen
- Clicks, mouseOvers, etc.
Try It
Conditional Statements
- True or False
- Execute when conditions met
Try it
Loops
- Repeat execution
1 | for (var index = 0; index < array.length; index++) { |
Try it
Functions
- Like a macro
- Can have parameters
Try it
—
## jQuery
- JS Library
- Fixes incompatibilities
- Uses the $ variable
—
## Try it