
Set 1 consists of one line of JavaScript code. Line 1: var cust equals new Customer open parenthesis open double quotes Sue close double quotes comma open double quotes 123 Somewhere close double quotes comma open double quotes Calgary close double quotes close parenthesis semicolon. Line 1 of set 1 is labeled 1 A brand new empty object is created and given the name cust. Set 2 consists of four lines of code. Line 1: function Customer open parenthesis name comma address comma city close parenthesis open curly brace, at indentation level 0. An arrow labeled Note: it is a coding convention to capitalize the first letter of a constructor function points to Customer in line 1 of set 2. An arrow labeled Then the function is called points from Customer in line 1 of set 1 to line 1 of set 2. Line 2: this dot name equals name semicolon, at indentation level 1. An arrow labeled 3 The new empty object is set as the context for this. Thus, the new empty object gains these property values points to line 2 of set 2. Line 3: this dot address equals address semicolon is, at indentation level 1. Line 4: this dot city equals city semicolon is, at indentation level 1. An arrow labeled 4 Since there is no return, the function will end with the (no longer empty) new object being assigned to the cust variable.
Back