






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Padua-Perez; Class: INTRO COMP PROG VIA WEB; Subject: Computer Science; University: University of Maryland; Term: Spring 2009;
Typology: Study notes
1 / 12
This page cannot be seen from the preview
Don't miss anything!







JavaScript does not support actual two-dimensional arrays
You can simulate two-dimensional arrays by using arrays of arrays
About two-dimensional arrays
You can pass them and return them from functions like one-dimensional arrays Any modifications in the function will be permanent You can have ragged arrays
Example: TwoDimensionalArrays.html
Example: Let’s define a two-dimensional array of strings
You use the. (period) operator to access an object’s properties A property value can be any data type we have seen including objects You can create your own objects by either: var myObj = {}; var myOtherObj = new Object(); You can create properties by assigning a value to it (we do not use var) myObj.created = “Monday”; You can update the property by assigning a new value You can delete a property with the delete operator delete myObj.created; You can check for the existence of a property using the “in” operator Example: ObjectEx.java
General form for (propertyName in object) statement Can be used to display the properties of an object for/in does not specify the order in which properties of an object are visited Example: ObjectEx.java The for/in does not loop through all the possible properties as some properties are considered non-enumerable User-defined properties are enumerable
Global object created by JavaScript interpreter when it starts up Interpreter initializes the Global object with predefined values and functions. For example, parseInt, Infinity, etc. Top-level code JavaScript code that does not belong to a function Global variables variables in top-level code Global variables are properties of the Global object. When you define a variable outside any function you are defining a global variable (a property of the global object) You should avoid using global variables in your code In client-side JavaScript the Window object (window) represents the global object for all JavaScript code present in the browser window You can use the keyword this to refer to the Global object Example: GlobalObject.html
SESSIONS
Session - time period during which a person views a number of different web pages in a browser and then quit What would you like To keep track of information throughout the session For example, keeping track of color preferences, usernames, data selection, etc. What is the problem? http (the protocol that makes possible the communication between browsers and web servers) is stateless (it has no memory) Stateless every page request is independent One Possible Solution Cookies
Cookies
Each cookie consists of name, value, expiration date, host, and path information This is how the cookie information may look like when sent by the server in the http header Set-Cookie: automobile=nelyota; path=/; domain=notRealCars.com If no expiration date is set for a cookie, the cookie expires when the user's session expires (i.e., when the user closes the browser) If the user accesses any page matching the path and domain of the cookie, the browser will resend the cookie to the server Let’s see cookies in our browser
Setting/Reading Cookies