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

Lecture 7: Introduction to JavaScript – I, Study notes of Object Oriented Programming

A. Javascript is a high-level language that is interpreted ... C. Special Requirements for JavaScript: • Javascript instructions are case sensitive. Most of.

Typology: Study notes

2022/2023

Uploaded on 02/28/2023

gangesha
gangesha 🇺🇸

4.6

(20)

239 documents

Partial preview of the text

Download Lecture 7: Introduction to JavaScript – I and more Study notes Object Oriented Programming in PDF only on Docsity!

  • 1 -

A. Lecture 7: Introduction to JavaScript – I

(^) Javascript is a high-level language that is

(^) interpreted

( compiler vs interpreter

). Javascript and HTML are

two

different

computer

languages.

Javascript

is

more powerful webpages.embedded in HTML file. Together they can create

B.

programmingMicrosystems (who developed Java), as a simple web^ Developed by Netscape, who worked jointly with Sun

language

in

The (^) language

is

supported

by most

browsers

(Netscape,

IE,

in 1991.)(HTML was developed at CERN for creating WWW

  • 2 -

C.

(^) Special Requirements for JavaScript

them are in lower case.Javascript instructions are case sensitive. Most of

interpreter will not recognize them.All instructions must be spelled correctly or the

and not run together.Parts of a instruction need to be separated by space

The correct punctuation must be used.

  • 3 -

D.

(^) Important Features of the Language

JavaScript allows for

(^) dynamic

(^) content while HTML

can only create

(^) static

(^) pages.

(interactive pages, event handling)^ Dynamic – webpage content changes overtime

(^) Static – the content of the page doesn’t change

machine, not remote server’s machine;Client-based: instructions are executed using user’s

server machine (security issue);Does not write files on either user's machine or the

Does not carry out graphics

  • 4 -

components:Each instruction is made of one or more of theObject Oriented Programming Language

(^) object, method & property

object:

  • e.g.: window, document, …a visual object

method:

  • e.g.: write(), alert(),…an action on an object

property:

  • e.g.: bgColor, status, …certain feature about an object

e.g.

document.bgColor = “red”;window.document.write(“Hello!”);

  • 5 -

E.

  • 6 -

F.

To insert it into HTML program, use

(^) window

(^) for the window object can be

tags. The output messages can be formatted using HTML document.write("This is just a statement"); assumed (ignored) – rewrite above as:

document.write("This is just a statement");

  • 8 -

the background, useanother instruction. For example, to change the color of We can change the color of parts of the document using^ 2) document.bgColor document.bgColor = "red";

background color of the webpage).on its right (color “red”) to the element on its left (the ‘=’ is an assignment operator which assigns the value

  • 13 -

There

(^) is an (^) alternative

(^) version

of (^) prompt()

(^) which

The returned to major.returned to major. If Cancel is clicked, a null value ismajor. When OK is clicked, the string in the text box isbe returned to major. The user can also type their own“CIS” already present. If the user clicks OK, “CIS” will Now, the user will see the text box with the string alert("Now I know your major is: " + major); var major = prompt("What is your major?", "CIS"); allows the programmer to give a default response: (^) + (^) operator connects pieces of messages together.