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 ClassA = function(){ | |
var a = 111; | |
this.b = 222; | |
this.show = function(){ | |
alert(this.b) | |
} | |
}; | |
ClassA.prototype.constructor = ClassA; | |
ClassA.prototype.showme = function(){ | |
alert(this.b) |
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 ClassA = function(){ | |
var a = 111; | |
this.b = 222; | |
this.show = function(){ | |
alert(a) | |
}; | |
}; | |
ClassA.prototype.constructor = ClassA; | |
ClassA.prototype.showme = function(){ | |
this.show(); |
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
//probability : 0.6(60%) | |
var getRandom = function(probability){ | |
var probability = probability*10 || 1; | |
var odds = Math.floor(Math.random()*10); | |
if(probability === 1){return 1}; | |
if(odds < probability){ | |
return 1; | |
}else{ | |
return 0; |
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 Module = (function(){ | |
var privateProperty = 'foo'; | |
function privateMethod(args){ | |
//do something | |
} | |
return { | |
publicProperty: "", |
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 module = function(){ | |
var current = null; | |
var labels = { | |
'home':'home', | |
'articles':'articles', | |
'contact':'contact' | |
}; | |
var init = function(){ | |
}; | |
var show = function(){ |
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 name = "Baggins"; | |
(function () { | |
// Outputs: "Original name was undefined" | |
console.log("Original name was " + name); | |
var name = "Underhill"; | |
// Outputs: "New name is Underhill" |
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
module.exports = function(grunt) { | |
// 项目配置. | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
uglify: { | |
options: { | |
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' | |
}, | |
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
<h1>{{blog.title}}</h1> | |
Published: {{blog.published}} | |
<p/> | |
{{blog.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 fs = require("fs"); | |
var express = require("express"); | |
var host = "127.0.0.1"; | |
var port = 1234; | |
var index = fs.readFileSync('index.html'); | |
var app = express(); | |
app.use(app.router); //use both root and other routes below | |
app.use(express.static(__dirname + "/")); //use static files in ROOT/public folder |