This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 先定义一个Person类 | |
var Person = function (name, age) { | |
this.name = name; | |
this.age = age; | |
this.tmp = 'this.tmp'; | |
this.sayName = function() { | |
console.log('this.sayName(): ', this.name); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Returns a copy of the specified string with special regular expression | |
characters escaped, allowing the string to be used safely inside a regex. | |
The following characters, and all whitespace characters, are escaped: | |
- $ ^ * ( ) + [ ] { } | \ , . ? | |
If _string_ is not already a string, it will be coerced to a string. | |
@method regex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- content to be placed inside <body>…</body> --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var source ='\ | |
{{#each types.type}}\ | |
<h2>{{this}}</h2>\ | |
<p>{{#test ../this }}{{/test}}</p>\ | |
{{/each}}\ | |
' | |
var data = { | |
types: { | |
type: [ | |
'o', 'k' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* mkdir -p for node */ | |
var fs = require('fs'), | |
path = require('path'); | |
function mkdirpSync (pathes, mode) { | |
mode = mode || 0777; | |
var dirs = pathes.trim().split('/'); | |
if (dirs[0] == '.') { | |
// ./aaa | |
dirs.shift(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Combine JS and CSS files | |
// --- | |
// | |
// Make sure you install the npm dependencies | |
// > cd YOUR_PROJECT_FOLDER | |
// > npm install | |
// | |
// Than run: | |
// > node build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!SLIDE | |
# 前端组2012Q4工作总结 - 巩守强 | |
!SLIDE | |
## | |
[Picture Show ためしてみたお( ^ω^) ](http://d.hatena.ne.jp/xuwei/20110903/1315044919) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Feature detect + local reference | |
var storage, | |
fail, | |
uid; | |
try { | |
uid = new Date; | |
(storage = window.localStorage).setItem(uid, uid); | |
fail = storage.getItem(uid) != uid; | |
storage.removeItem(uid); | |
fail && (storage = false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(['module'], function (module) { | |
'use strict'; | |
var storage = (function(){ | |
var uid = new Date, | |
result; | |
try { | |
localStorage.setItem(uid, uid); | |
result = localStorage.getItem(uid) == uid; | |
localStorage.removeItem(uid); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function throttle( fn, time ) { | |
var t = 0; | |
return function() { | |
var args = arguments, ctx = this; | |
clearTimeout(t); | |
t = setTimeout( function() { | |
fn.apply( ctx, args ); | |
}, time ); | |
}; |