Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

JavaScript Object Programming - Introduction to Java Script - Lecture Slides, Slides of Javascript programming

Here is my collection on JavaScript lectures. It includes tutorials as well as general concepts explanations. Particularly these slides contain: Javascript Object Programming, Reusable Software, Data, Encapsulation, Classes, Built-In Javascript Classes, Array Class, Date Class, Math Class Methods, Custom Javascript Objects, Properties,

Typology: Slides

2013/2014

Uploaded on 01/29/2014

surii
surii 🇮🇳

3.5

(13)

130 documents

1 / 45

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Object-Oriented Java Script
Object-Oriented
JavaScript
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d

Partial preview of the text

Download JavaScript Object Programming - Introduction to Java Script - Lecture Slides and more Slides Javascript programming in PDF only on Docsity!

Object-Oriented Java Script

Object-Oriented

JavaScript

Objectives

  • Study object-oriented programming
  • Learn about the built-in JavaScript objects
  • Work with the Array, Date, Math, and Number objects
  • Define custom JavaScript objects

Reusable Software

  • Object-oriented programming (OOP):
    • Refers to the creation of reusable software objects that can be easily incorporated into multiple programs
  • Object:
    • Specifically refers to programming code and data that can be treated as an individual unit or component

Reusable Software (Cont.)

  • Data:
    • Refers to information contained within variables or other types of storage structures
  • Objects can range from simple controls such as a button, to entire programs such as a database application - In a retail sales program, you could refer to all the code that calculates the sales total as a single object. - You could reuse the object over and over again in the same program by typing the object name.

Encapsulation

  • Objects are encapsulated:
    • All code and required data are contained within the object itself
  • Encapsulation:
    • Places code inside what programmers like to call a “black box”
    • When an object is encapsulated, you cannot see “inside” it—all internal workings are hidden

Encapsulation (Cont.)

  • The code (methods and statements) and data (variables and constants) contained in an encapsulated object are accessed through an interface
  • Interface:
    • Represents elements required for a source program to communicate with an object - Interface elements required to access a Payroll object might be a method named calcNetPay()

Encapsulation (Cont.)

  • Encapsulation prevents other programmers from:
    • Accidentally introducing a bug into a program
    • Stealing the code and claiming it as their own

Encapsulation (Cont.)

Classes (Cont.)

  • A particular instance of an object inherits its methods and properties from a class:
    • It takes on the characteristics of the class on which it is based
    • For Example Consider an object called BankAccount that contains methods and properties that you might use to record transactions associated with a checking or savings account - The BankAccount object is created from a BankAccount class - To use the BankAccount class you create an instance of the class - A particular instance of an object inherits its methods and properties from a class - The BankAccout object inherits all its methods and properties from the BankAccout class

Classes (Cont.)

  • Class names in traditional object-oriented programming usually begin with an uppercase letter. This convention is also followed in JavaScript

Instantiating an Object

  • You can use some of the built-in JavaScript objects directly in your code - document.write(“The value of PI is “ + Math.PI);
  • Other objects require you to instantiate a new object
    • var studentList = new Array()

Garbage Collection

  • When you instantiate a new object, you are reserving memory
  • Refers to cleaning up, or reclaiming, memory that is reserved by a program
  • JavaScript knows when a program no longer needs a variable or object - Automatically cleans up the memory

Array Class Methods

The Length Property

  • Returns the number of elements in an array
  • You append the length property to the name of the array you want to sort using the following syntax: array_name .length;