随笔分类 -  Javascript

摘要:Leaflet makes creating maps in the browserdead simple. With some HTML and 3 lines of JavaScript, we can quickly have a map displaying// create a map i... 阅读全文
posted @ 2015-03-20 23:16 Zhentiw
摘要:window.onload = function() { var canvas = document.getElementById("canvas"), context = canvas.getContext("2d"); var gradient =context.cre... 阅读全文
posted @ 2015-03-20 04:50 Zhentiw
摘要:window.onload = function() { var canvas = document.getElementById("canvas"), context = canvas.getContext("2d"), width = canvas.width = 600,... 阅读全文
posted @ 2015-03-19 23:39 Zhentiw
摘要:window.onload = function() { var canvas = document.getElementById("canvas"), context = canvas.getContext("2d"); context.beginPath(); c... 阅读全文
posted @ 2015-03-19 22:00 Zhentiw
摘要:HTML5 Canvas Graphics and Animation/** * Created by Answer1215 on 3/19/2015. */window.onload = function() { //var canvas = $("#canvas")... 阅读全文
posted @ 2015-03-19 21:34 Zhentiw
摘要:sortBy:var collection = ['John', 'Petteri', 'Antti', 'Joonas', 'Zhentian'];var sorted = _.sortBy(collection);//[ 'Antti', 'John', 'Joonas', 'Petteri',... 阅读全文
posted @ 2015-03-04 03:52 Zhentiw
摘要:Using ES6To use ES6, we need loader.Modify webpack.config.js file:module.exports = { entry: './index.js', output: { filename: 'bundle.js'... 阅读全文
posted @ 2015-03-04 03:21 Zhentiw
摘要:To use webpack, first you need to run:npm install webpack2. Create a webpack.config.js file:module.exports = { entry: './index.js', output: { ... 阅读全文
posted @ 2015-03-03 04:17 Zhentiw
摘要:1 //search 2 bower search jquery 3 4 bower search jquery | grep formstyler 5 6 //info 7 bower info jquery 8 9 //install (lastest one)10 bower inst... 阅读全文
posted @ 2014-12-22 04:46 Zhentiw
摘要:We have code like:var numbers = [1,2,3];for(var i in numbers){ setTimeout(function(){console.log(numbers[i]); }, 0);}//3//3//3Note:1. function... 阅读全文
posted @ 2014-12-17 18:47 Zhentiw
摘要:var people = [ {name: "Rank", age: 40}, {name: "Bob", age: 35}, {name: "Gegg", age: 30}, {name: "Leate", age: 18}, {name: "Matti", age: 34}, {na... 阅读全文
posted @ 2014-10-10 20:26 Zhentiw
摘要:Read More:http://joelhooks.com/blog/2014/02/06/stop-writing-for-loops-start-using-underscorejs/How many for loops did you write today? This week?12345... 阅读全文
posted @ 2014-10-09 05:38 Zhentiw
摘要:1. Want to use bower you need to have node npm and git. 2. Download node.js and git if you don't have. 3. Add nodejs and git & git cmd into the PATH. 阅读全文
posted @ 2014-08-31 05:13 Zhentiw
摘要:/** Augmentation*/var wartime = true;var ARMORY = (function( war ){{ //add var to the private properties var weaponList = [*list of weapon ob... 阅读全文
posted @ 2014-08-17 20:31 Zhentiw
摘要:/** Global Imports*/var wartime = true;var ARMORY = (function(){{ //add var to the private properties var weaponList = [*list of weapon objec... 阅读全文
posted @ 2014-08-17 20:30 Zhentiw
摘要:/** 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