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* fibGen (current, next) { | |
| yield current | |
| yield* fibGen(next, current + next) | |
| } | |
| for (var num of fibGen(0,1)); | |
| // function* fibGen (current, next) { | |
| // ^ | |
| // RangeError: Maximum call stack size exceeded |
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
| if (!this.props.isInitialized) { | |
| return ( | |
| <FlexRow> | |
| <FlexColumn> | |
| <EMap bingKey={this.props.bingKey} active={true} /> | |
| </FlexColumn> | |
| </FlexRow> | |
| ) | |
| } |
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
| // Prototypal Inheritance (this function will eventually be in the JavaScript language) | |
| if (typeof Object.create !== 'function') { | |
| Object.create = function(o) { | |
| function F() {} | |
| F.prototype = o; | |
| return new f(); | |
| } | |
| } |
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 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |
| <head> | |
| <meta http-equiv="content-type" content="text/html; charset=utf-8"/> | |
| <title></title> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |
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 singleton = function() { | |
| var privateVariable; | |
| function privateFunction(x){ | |
| //privateVariable | |
| } | |
| return { | |
| firstMethod: function(a, b) { | |
| //privateVariable | |
| }, | |
| secondMethod: function(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
| /* in few words:no round brackets=function or object, round brackets:anything, arguments.callee included.diff is the left assignment */ | |
| var a = function(){return 1}(); // 1 | |
| var b = function(){return {}}(); //object | |
| function(){return 1}(); //error | |
| function(){return {}}(); //error | |
| var c = (function(){return arguments.callee})(); //function | |
| var d = (function(){return []})(); //array |
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
| /* | |
| evaluates as a block — "{" and "}" — containing one labeled statement — `a:"a"`. | |
| labeled statement, in its turn, evaluates to "a". | |
| */ | |
| {a:"a"} | |
| /* | |
| evaluates as an expression, where "(" and ")" are grouping operator and "{" and "}" constitute an object literal. | |
| evaluates to this object value. |
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 = {}; | |
| //to note: nothing is passed in and no private variables/functions/etc. on purpose | |
| var b = (function(){ | |
| return {}; | |
| })(); | |
| /* | |
| Is there any difference between a and b in regards to scope/execution? Any advantage one has over the other? (besides like arguments.callee/recursive stuff); | |
| */ |
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
| if (!navigator.geolocation) { | |
| navigator.geolocation = (function (window) { | |
| function getCurrentPosition(callback) { | |
| // NOTE: for some reason, chaging the url is *allowed* with this service. Useful, but random | |
| // source: http://www.maxmind.com/app/javascript_city | |
| // The source is open source, as per: http://www.maxmind.com/app/api, but doesn't discuss specific license use. Hopefully it's just free to use - yay internet! | |
| var geourl = 'http://j.maxmind.com/app/geoip.js_' + Math.random(), | |
| iframe = document.createElement('iframe'), | |
| doc, win; |
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 sys = require("sys") | |
| var http = require("http"); | |
| var twitter = http.createClient(80, "search.twitter.com"); | |
| var count = 10 | |
| for (var i = 1; i <= count; i++) { | |
| var request = twitter.request("GET", "/search.json?q=crockfordfact+OR+crockfordfacts&rpp=100&page=" + i, {"host": "search.twitter.com"}); | |
| request.addListener('response', function(response) { |
OlderNewer