Download presentation
Presentation is loading. Please wait.
1
Recognizing JavaScript Features
Kevin Harville
2
Review this slide each week until you know the points completely.
The purpose of these slides is to help you recognize the parts of the JavaScript language. Some of the information will need to soak in over time!
3
Objects Objects are things. Objects have properties.
Objects have methods. Methods are things an object does. Example of an object and a property: window.status = “Hello”
4
Objects Objects are things. Objects have properties.
Objects have methods. Methods are things an object does. Example of an object and a method: document.write(“<h1>Hello<h1>”)
5
Examples of Objects Browser windows HTML documents Forms Form Elements
Links We use a hierarchy of objects, known as the Document Object Model.
6
Other objects JavaScript refers to numerous rather abstract things as objects as well: Dates Strings Arrays of Variables Even Math functionality is handled on an object-oriented basis. This will make more sense as we go on.
7
Making your own objects
Using data in an object-oriented fashion is new, so somewhat intimidating. Once you understand the framework, though, It actually makes programming and data-handling easier. You will even make your own objects!
8
Making Your Own Objects
Suppose you are making a space game. You may make a spaceship object. You can then program using its properties and methods: spaceship.move(4) spaceship.shields = 7
9
Object summary There are three types of objects we deal with:
Built-in Objects: JavaScript objects to provide programming functionality Browser Objects: Document Object Model objects that work with the functionality of your browser. Custom Objects: Objects we make for our own programming purposes.
10
Variables Variables are names we give to a space on the computer that holds a value. That value may change over time. Lets make some variables: Var myNullValue //not filled; var myVariable = “Hello World”; var myNumber = 24;
11
Functions Functions are similar to methods. Actually methods are functions. Functions in JavaScript take the role of a function or subroutine in Visual Basic. They may or may not return a value. They perform a particular task or calculation.
12
Recognizing Functions
Calling the function from HTML: onClick = “return sayHello(‘Hi Class’);” And in the script in the head section: Function sayHello(myGreeting){ alert(myGreeting); }
13
Event Handlers Event Handlers are sections of javascript written into special HTML attributes. <input type = “button” onClick = “return sayHello(‘Hi Class’);” >
14
Event Examples onClick onLoad onMouseOver onMouseDown onMouseOut
Several Others
15
Parameters Parameters are the values passed into a function or method.
return sayHello(‘Hi Class’); return sayHello(myVariable); In VB we referred to parameters as attributes.
17
Concept Summary Objects Properties Methods Functions Variables Events
Parameters
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.