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
| // i understand THAT javascript doesn't assume a `;` before `return` in | |
| // these examples. but i don't understand WHY it can't? why didn't they | |
| // say that the grammar for `return` always assumes the previous statement | |
| // is complete? | |
| // NOTE: david baron pointed out that `if(a)return;` definitely wouldn't want | |
| // to have this assumption. good point. but the others? | |
| // NOTE: assume all these are inside a function, so `return` is safe. |
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
| // NOTE: only escapes a " if it's not already escaped | |
| function escapeDoubleQuotes(str) { | |
| return str.replace(/\\([\s\S])|(")/g,"\\$1$2"); // thanks @slevithan! | |
| } | |
| escapeDoubleQuotes(`ab`); // ab => ab (nothing escaped) | |
| escapeDoubleQuotes(`a"b`); // a"b => a\"b | |
| escapeDoubleQuotes(`a\\"b`); // a\"b => a\"b (nothing escaped) | |
| escapeDoubleQuotes(`a\\\\"b`); // a\\"b => a\\\"b | |
| escapeDoubleQuotes(`a\\\\\\"b`); // a\\\"b => a\\\"b (nothing escaped) |
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
| { | |
| "settings" : { | |
| "foo" : "low", | |
| "bar" : "high", | |
| "baz" : "low" | |
| } | |
| } |
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
| {$: '#settings' } | |
| <h1>Settings</h1> | |
| {$* $.settings | name = _.key | options['low','high'] = _.value ? "checked" } | |
| <h2>{$= name $}</h2> | |
| {$* options } | |
| <input type="radio" name="{$= name $}" value="{$= _.key $}" {$= _.value $}> {$= _.key $} | |
| {$} | |
| {$} | |
| {$} |
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
| Here is some text | |
| that crosses multiple lines | |
| and sed sucks. What is | |
| the point of sed? |
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 __3__(G) { | |
| var partial = G.definePartial, | |
| clone = G.cloneObj, | |
| extend = G.extend, | |
| cID = "3"; | |
| partial(function __settings__($, _) { | |
| $ = clone($) || {}; | |
| _ = clone(_) || {}; | |
| var i, ret = "", | |
| ret2, $$; |
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
| // this jquery works: | |
| $("<script></script>").attr({src: "blah.js"}).appendTo(document.head); | |
| // this bonzo doesn't work: | |
| bonzo(bonzo.create("<script></script>")).attr({src: "blah.js"}).appendTo(document.head); | |
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
| <dict> | |
| <key>name</key> | |
| <string>JSON String</string> | |
| <key>scope</key> | |
| <string>meta.structure.dictionary.json string.quoted.double.json</string> | |
| <key>settings</key> | |
| <dict> | |
| <key>foreground</key> | |
| <string>#E6DB74</string> | |
| </dict> |
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: poor stylistic form, but no leakage | |
| function foo() { | |
| bar = 3; | |
| if (true) { | |
| var bar = 5; | |
| } | |
| } | |
| // let: will leak an auto-global | |
| function foo() { |
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
| /* | |
| not terribly difficult to predict which statements print what. | |
| */ | |
| function foo() { | |
| var a, b, c, d; | |
| if (true) { | |
| if (true) { | |
| a = 1; |