随笔分类 -  Javascript

上一页 1 ··· 26 27 28 29 30
摘要:Sometime, use can rewrite the toString , valueOf method to make those function more useful: For exmaple, we can make valueOf() function to calcualte t 阅读全文
posted @ 2014-08-11 02:53 Zhentiw
摘要:function Fencepost (x, y, postNum){ this.x = x; this.y = y; this.postNum = postNum; this.connectionsTo = []; } Fencepost.prototype = { sendRopeTo: fun 阅读全文
posted @ 2014-08-10 17:59 Zhentiw
摘要:You can add prototype to any object in Jacascript likes Object, Array, String... prototype 有继承的作用,比如说我有一个String的对象,我可以访问Object的prototype hasPrototype( 阅读全文
posted @ 2014-08-10 02:32 Zhentiw
摘要:var vehicle1 = {type: "Motorboat", capacity: 6, storedAt: "Ammunition Depot"}; var vehicle2 = {type: "Jet Ski", capacity: 1, storedAt: "Reef Dock"}; v 阅读全文
posted @ 2014-08-08 00:31 Zhentiw
摘要:First, memory is set aside for all necessary variables and declared functions. Function expression never got hosited in Javascirpt. Therefore, you can 阅读全文
posted @ 2014-08-05 16:21 Zhentiw
摘要:They’ve got a problem with their existing code, which tries to use a closure. Check it out: function assignLaser( shark, sharkList ){ var stationAssig 阅读全文
posted @ 2014-08-04 20:57 Zhentiw
摘要:function buildCoveTicketMarker(transport){ var passengerNumber = 0; return function(name){ passengerNumber++; alert("Ticket via the " +transport+ "Wel 阅读全文
posted @ 2014-08-04 20:15 Zhentiw
摘要:Returning a function from a function, complete with variables from an external scope, is called a closure. The entire contents of one of these inner f 阅读全文
posted @ 2014-08-04 18:33 Zhentiw
摘要:The Poplar Puzzle-makers weren’t too impressed. They barely noticed your simple and beautiful array of functions, and were only sort of “meh” on the u 阅读全文
posted @ 2014-08-02 20:52 Zhentiw
摘要:Now the people at Poplar Puzzles would like you to treat an array of functions like a Queue, passing the result of each function into the next until t 阅读全文
posted @ 2014-08-02 20:29 Zhentiw
摘要:var parkRides = [["Birch Bumpers", 40], ["Pines Plunge", 55], ["Cedar Coaster", 20], ["Ferris Wheel of Firs". 90]]; var fastPassQueus = ["Cedar Coaste 阅读全文
posted @ 2014-08-02 19:50 Zhentiw
摘要:As an example, if Jason was riding the roller coaster (and when isn’t he), your goal would be to change his cell from ["Jason", "Millhouse"] to just " 阅读全文
posted @ 2014-08-02 18:00 Zhentiw
摘要:Inside the Haunted Hickory House file, developers for the Forest of Function Expressions Theme Park have created a declared function called forestFrig 阅读全文
posted @ 2014-08-02 17:23 Zhentiw
摘要://This will load the code into the memory no matter //you call it or not function diffOfSquares(a,b){ return a*a -b*b; } //This code will only load in 阅读全文
posted @ 2014-08-02 16:37 Zhentiw
摘要:思想:创建三个类,一个Boss类,管理Worker的分配,统计worker和Task的个数。Worker类,管理这个worker自己的Task。Task类。//Boss类function Boss(){ this.workerList = new Array(); this.totalW... 阅读全文
posted @ 2013-05-30 06:12 Zhentiw
摘要:组合使用构造函数模式和原型模式(优化方案) 方式: 构造函数模式用于定义实例属性,而原型模式用于定义方法和共享属性。 代码:要求编写一段程序,实现统计人数,给每个人分配姓名,年龄,工作等属性,并且可以给每个人分配好友,并且可以查看好友的信息。 Javascript代码: //构造函数模式用于定义实例 阅读全文
posted @ 2013-05-30 06:05 Zhentiw

上一页 1 ··· 26 27 28 29 30