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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> | |
| funcProto = Function.prototype |
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
| values(property, values) | |
| length = length(values) | |
| for value, index in values | |
| &:nth-child({length}n + {index}) | |
| {unquote(property)} value | |
| /* li | |
| * values(background-color, #8185cd #7cd7c5 #65adeb #ee8e69) | |
| * | |
| * yields |
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($) { | |
| var $window = $(window) | |
| var $document = $(document) | |
| var contexts = [] | |
| var maxScrollTop = $document.height() - $window.height() | |
| var currentScrollTop = $window.scrollTop() | |
| function Context($parent, $background, $caption) { | |
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
| flatten = (list, result = []) -> | |
| for value in list | |
| if Array.isArray value | |
| flatten value, result | |
| else | |
| result.push value | |
| return result | |
| console.log flatten [(->), [[new Date], /foo/g]] |
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
| flatten = (list, result = []) -> | |
| for value in list | |
| if Array.isArray value | |
| flatten value, result | |
| else | |
| result.push value | |
| return result | |
| console.log flatten [(->), [[new Date], /foo/g]] |
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
| flatten = (list) -> | |
| result = [] | |
| lists = [] | |
| while list? and not list in lists | |
| lists.push list | |
| result.push list[0] | |
| list = list[1] | |
| return result | |
| console.log flatten [1, ['foo', [(->), [a: no, [new Date, [/bar/g]]]]]] |
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
| #!/bin/sh | |
| jade -P -w *.jade & | |
| stylus -u nib -w style.styl & | |
| coffee -c -w *.coffee |
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
| {} + [] // => {}; +[] => 0 | |
| [] + {} // => '' + '[object Object]' => '[object Object]' | |
| {} + [] == [] + {} // => {}; 0 == '[object Object]' => false | |
| ({} + [] == [] + {}) // => '[object Object]' + '' == '' + '[Object Object]' => 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
| #!/usr/bin/env coffee | |
| module.exports = SimpleAsync = (funcs...) -> | |
| callback = (args...) -> | |
| funcs.shift()? args..., callback | |
| return | |
| inner = (argsOrFuncs...) -> | |
| if typeof argsOrFuncs[0] is 'function' | |
| funcs.push argsOrFuncs... | |
| inner |
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 x = 10; | |
| foo = { | |
| x: 20, | |
| bar: function () { | |
| var x = 30; | |
| return this.x; | |
| } | |
| } | |
| /* |