Download presentation
Presentation is loading. Please wait.
Published byRhoda Cameron Modified over 9 years ago
1
Introduction to Programming and JavaScript
2
Programming
3
What is a Program? Instructions Computer Understands Perform Task
4
What is Programming? Requirements Process Code Test
5
Types of Programs OS/Hardware Application Runtime Module Script Processor Interpreter Byte Code Executable (Machine Code) Compiler Macro/Script Applet Executable Program Interpreted Program Source Code Source Code Source Code Source Code Virtual Machine
6
Object Oriented Programs OOP
7
Basics of Objects Interface Print this, Current ink level?, Out of paper!, … ? Properties Ink level, Paper in tray, … Methods Print page, Eject page, …
8
Algorithms and Programs Algorithm Program Effective Efficient Reliable Understandable Maintainable
9
Control Structures SequenceConditional Open File Format File Print File Save File Close File Get Section Status Section Full? Register Student Reject Registration NoYes
10
Control Structures Loop Open Student File Get Student Record Print Grade Report Students Left? Close Student File Yes No Transfer (GoTo) Open File Print File Format File Close File Save File Spaghetti Code!
11
JavaScript function shutdown() { alert('Shutting Down Internet.') }
12
JavaScript A programming language. Executed as a script. Object oriented. Extensive document object model (DOM). No file read/write access (except cookies). function shutdown() { alert('Shutting Down Internet.') }
13
Program code written in JavaScript. JavaScript comments. NO HTML!
14
Script Locations … Script is reusable. “Call” script to execute it. … Script is executed as the browser displays the web page. External Script File
15
At start of body. Alert users without JavaScript support.
16
Objects, Events, & Event Handlers Object Click button = Click Event Shutdown Internet? <input type="button" value="Shutdown Internet" onclick="shutdown()" /> function shutdown() { alert('Shutting Down Internet.') }
17
Comments Please! JavaScript code … // comment JavaScript code … /* comment */ JavaScript code … /* comment continues on this line and on this line */ JavaScript code … /* comment starts on this line and continues on this line and on this line */
18
Bugs – Syntax Errors function shutdown() { do alert('Shutting Down Internet.') } Shutdown Internet? <input type="button" value="Shutdown Internet" onclick="shutdown()" /> line 8 error is here!
19
Bugs – Runtime Errors function shutdown() { alert('Shutting Down Internet.') } Shutdown Internet? <input type="button" value="Shutdown Internet" onclick="do_onclick()" />
20
Bugs – Logic Errors function compute_gross_pay(hours, rate) { Gross = hours + rate return Gross }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.