PencilCoder

Date Objects!

Goals:

  • Access system time using the Javascript Date object.
  • Learn more about the Javascript Object data type.

Coding Snippets:

  • coding snippets
  • Create an object representing the current date and time by calling the Date constructor with no arguments.
  • Create an object representing a specific date by passing numeric year, month, and day arguments to the Date constructor. Note: the month argument is zero based.
  • Use dot notation to call functions which provide information about a Date object.

Math and Computer Concepts:

  • Javascript includes several built-in object types, such as Array and Date. Pencil Code adds more, such as Turtle and Sprite.
  • Objects differ from other data types, such as Number and String, in that they can store collections of different data types in a single unit. For example, Turtle objects store information about a specific turtle's size, color, location, and orientation.
  • As with Turtle objects, information about a specific Date object can be accessed via functions, a few of which are listed above. The Date constructor also accepts additional arguments. Look up an online code reference for the Date object, such as at w3Schools.com, to explore other features of this useful object.

Activities:

Save each of the following in a folder called Objects.