随笔分类 - Javascript
摘要:/** So far, we've seen a module that has only public properties*//*The thing with a namespace is that you have to hope that no oneelse ever uses it...
阅读全文
posted @ 2014-08-17 20:28
Zhentiw
摘要:/** Retrieving and using numerical time data*/var rightnow = new Date();console.log(rightnow); //Tue Aug 12 2014 22:07:01 GMT+0300 (FLE Daylight Ti...
阅读全文
posted @ 2014-08-14 03:43
Zhentiw
摘要:Let's take a closer look at how a browser retrieves and acts on scripts.modern browser can parallel downloading 6 files(style sheets && images)at a ti
阅读全文
posted @ 2014-08-12 20:42
Zhentiw
摘要:/** Improve you loop code */ var treasureChest = { goldCoins: 10000, magicalItem : "Crown of Speed", necklaces: ["ruby", "pearl", "sapphire", "diamond
阅读全文
posted @ 2014-08-12 20:26
Zhentiw
摘要:/** Ternary Conditionals */ // //**Bad** // var isArthur = false; var weapon; if(isArthur){ weapon = "Excalibur"; }else{ weapon = "Longsword"; } // //
阅读全文
posted @ 2014-08-11 03:45
Zhentiw
摘要: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

浙公网安备 33010602011771号