So it is necessary to give an example here for the students:
JavaScript Object-Oriented code example
<textarea id="runcode58501"><script type= "Text/javascript" >//Create a site constructor, name and URL is its parameter function site (name, url) {this.url = URL; THIS.name = name; ///Add a method for site to display the URL Site.prototype.show = function () {return this.name+ "URL is:" +this.url; }; Creates a site collection constructor, Sites is its parameter function Sites (Sites) {this.sites = Sites; ///Add a method for Sites to display the URL Sites.prototype.show = function () {var retstr = ""; for (Var i=0;i<this.sites.length;i++) {retstr+=this.sites[i].show () + ""; return retstr; }; Create a new site collection, including Dream capital, Baidu, google var mysites = new Sites ([New Site ("cloud-Habitat community", "Www.jb51.net"), new site ("Baidu", "www.baidu.com"), new Site ("Google", "www.google.com")]; Print site URL document.write (mysites.show ()); </script></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]