Skip to content

Instantly share code, notes, and snippets.

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);
})();
console.log('1:');
(function() {
if (true) {
var a = 'a';
}
console.log(a);
if (false) {
var b = 'b';
}
console.log(b);
console.log('1:---');
(function() {
var o1 = {
name: 'a1'
};
var o2 = o1;
o2.name = 'o2';
console.log(o1.name);
})();
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
}
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

Lightbox Widget

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.

A Pen by famo.us on CodePen.

License.

@lyuehh
lyuehh / rept
Created November 18, 2013 15:35
#!/bin/sh
if [ $# -ne 3 ];
then
echo "need 3 args.."
exit 1
fi
for((i=0;i<$1;i++))
do
var check = function(value, type, blackData, whiteData) {
var blackDataObj = _.groupBy(blackData, function(i) {
var flag = (i.target.indexOf('@') !== -1) ? "email" : "domain";
return flag;
});
var whiteDataObj = _.groupBy(whiteData, function(i) {
var flag = (i.target.indexOf('@') !== -1) ? "email" : "domain";
return flag;
});
// todo...
<!DOCTYPE html>
<html lang="zh-CN">
  ...
</html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@lyuehh
lyuehh / README.md
Created September 2, 2013 14:58 — forked from rkirsling/LICENSE

Click in the open space to add a node, drag from one node to another to add an edge.
Ctrl-drag a node to move the graph layout.
Click a node or an edge to select it.

When a node is selected: R toggles reflexivity, Delete removes the node.
When an edge is selected: L(eft), R(ight), B(oth) change direction, Delete removes the edge.

To see this example as part of a larger project, check out Modal Logic Playground!