Javascript




CS174

Chris Pollett

Apr 10, 2017

Outline

Javascript

We now want to consider adding dynamic behaviors to our websites as they are interacted with on the client-side. To do this, we will use the Javascript language.

Uses of Javascript

Quiz

Which of the following statements is true?

  1. Git keeps prior commits of a repository in a .git folder.
  2. GitHub can only be used as an issue tracker for git repositories.
  3. To apply a git patch one can execute the line:
    git commit <  name_of_patch.txt
    

Objects in Javascript

General Overview

Lexicon

Example Javascript and HTML document

<html>
<head><title>test</title>
<meta name="description" value="this example illustrates how Javascripts are executed both when the document is loaded and on the occurrence of events" />
<script type="text/javascript" >
   function sayHello()
   {
      alert("hi there");
   } 
</script>
</head><body><form><input type="button" value="test" onclick="return sayHello();" 
/><!-- responds to events --></form>
<script type="text/javascript" >
for( i = 0; i<100; i++) { 
    document.writeln("<p>hi"+i+"</p>");
} // run when document loads
</script></body>
</html>

Primitives

Variables

Numeric Operators and Objects

Strings and Type Conversion

typeof, Assignments, and the Date Object

I/O

Control Statements

Objects

Arrays

More Arrays