Logotyp

Programspråksteori, dt096g

Lokal inloggning

Lab assignment prototyping

Overview

The objective of this lab is to investigate the Javascript prototype programming paradigm as well as closures.

Deliverables

A complete implementation in JavaScript embedded in a html page or a standalone e.g. nodejs implementation.
The lab report is created in a formatted text document, preferrably pdf format.
The report should contain at least one a4 page of formatted text discuss your thoughts on the prototype mechanism, in particular in regards to the traditional OO design. Use this knowledge to expand on the evaluation of javascript as a language from the first presentation session, include this in your report.

Implementation

Create a Javascript class(es) implementing the Iterator pattern on standard javascript Array objects. It is convinient to follow a Java-like iterator implementation.

1 - using regular objects, i.e. an Iterator constructor function closing over an array.

2 - using the prototype mechanism. Let every array object have an iterator() accessor.

Use your iterator to iterate over an array of

Förtydligande Lab 2

Implementationen ska möjliggöra iteration som
while(it.hasNext()){
console.log(it.next());
}