An example of a famo.us lightbox widget. The lightbox flips between thumbnail and detail view when an item is clicked. Edit the grid layout using the sliders. Animations are powered by both easing curves and physics animations.
This file contains hidden or 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 foo = 1; | |
function main(){ | |
alert(foo); | |
var foo = 2; | |
alert(this.foo); | |
this.foo = 3; | |
} | |
var m1 = main(); //undefined 1 | |
var m2 = new main(); // undefined undefined |
This file contains hidden or 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 a = 1; // 全局变量 | |
function b(){ | |
a = 2; // 没有var, 就是全局, a变成2了 | |
console.log(a); // 输出2 | |
a = 3; // a变成3了 | |
setTimeout(function(){ //只要是setTimeout, 它就会异步执行, 就算延迟0秒也会异步, 所以这里不会执行了 | |
console.log(a); | |
}, 0); | |
a = 4; // 修改a为4 | |
} |
This file contains hidden or 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
console.log('1:---'); | |
(function() { | |
var o1 = { | |
name: 'a1' | |
}; | |
var o2 = o1; | |
o2.name = 'o2'; | |
console.log(o1.name); | |
})(); |
This file contains hidden or 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
console.log('1:'); | |
(function() { | |
if (true) { | |
var a = 'a'; | |
} | |
console.log(a); | |
if (false) { | |
var b = 'b'; | |
} | |
console.log(b); |
This file contains hidden or 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
console.log('1:'); | |
(function() { | |
var a = [1,2,3,4]; | |
console.log(a.length); | |
a.length = 2; | |
console.log(a); | |
a.length = 4; | |
console.log(a); | |
})(); |
This file contains hidden or 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
console.log('1:'); | |
(function() { | |
console.log(add(1, 2)); | |
function add(a, b) { | |
return a + b; | |
} | |
})(); | |
console.log('2:'); | |
(function() { |
This file contains hidden or 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
//'use strict'; | |
var global = this; | |
(function() { | |
'use strict'; | |
// object | |
(function() { | |
var person = {}; | |
person.name = 'www'; |
This file contains hidden or 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() { | |
'use strict'; | |
// 6.3.1 prototype chaining | |
// bad: if the super object's attribute is ref, like array, then it share in all sub object. | |
// bad: you can't pass arguments into the supertype constructer when sub type instance is being created. | |
(function() { | |
function SuperType() { | |
this.property = true; | |
} |
This file contains hidden or 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
/* global console */ | |
var str = "hello world"; | |
console.log("str: " + str); | |
console.log(); | |
console.log("slice(3): " + str.slice(3)); | |
console.log("substring(3): " + str.substring(3)); | |
console.log("substr(3): " + str.substr(3)); |