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 = 'hello'; | |
| (function() { | |
| console.log(foo); // undefined! | |
| var foo = foo || 'world'; | |
| })(); |
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
| // override the bar prop for foo w/o affecting bim | |
| foo.bar = 'new value'; | |
| // change the bar prop for both foo and bim | |
| // (*if* it hasn't been overridden locally!) | |
| Thinger.prototype.bar = 'another new value'; | |
| // we could delete foo.bar now and it would get | |
| // the prototype value instead | |
| // delete foo.bar; |
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
| for (var obj in myObjects) { | |
| if (myObjects.hasOwnProperty(obj)) { | |
| myObjects[obj].destroy(); | |
| delete myObjects[obj]; | |
| } | |
| } |
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
| $(document).ready(function() { | |
| var handleClick = function(e) { | |
| var el = $(e.target); | |
| el.attr('title', 'new title') | |
| .width('100px'); | |
| }, | |
| bar = $('#bar') | |
| // ideally: use a class for this | |
| .css({ |
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() { | |
| dojo.xhrGet({ | |
| url : 'foo.php', | |
| load : function(resp) { | |
| if (resp && resp.foo) { | |
| // run this important code | |
| } | |
| } | |
| }); | |
| })(); |
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(d, $){ | |
| d.forEach(['foo', 'bar', 'baz', 'bop'], function(c) { | |
| $('li.' + c + ' a').attr('title', 'i am ' + c); | |
| }); | |
| })(dojo, dojo.query); |
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 calculateTotal(baseTotal, tip, tax, fee) { | |
| // convert the tip to a number using base 10; | |
| // allow for a NaN result from parseFloat | |
| tip = parseFloat(tip) || 0; | |
| // don't allow a negative tip | |
| if (tip < 0) { tip = 0; } | |
| return baseTotal + tip + tax + fee; | |
| } |
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 newArray = dojo.map(menuItems, function(item) { | |
| var ret = item.name; | |
| if (item.extras && item.extras.length) { | |
| ret += '(' + item.extras.join(', ') + ')'; | |
| } | |
| return ret; | |
| }); |
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 thingerDom = [], gizmoDom = [], | |
| tpl = '<p><span class="%s">i am %s %i</span></p>', | |
| tplFn = function(str, i) { | |
| return tpl.replace(/%s/g, str).replace(/%i/g, i); | |
| }, | |
| i; | |
| for (i = 0; i <= 100; i++) { | |
| thingerDom.push(tplFn('thinger', i)); | |
| gizmoDom.push(tplFn('gizmo', i)); |
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
| <ol class="action_menu"> | |
| <?php if ($User->IsLoggedIn() && $User->CanPublish() | |
| && $User->Articles->count() < $App->max_articles) { ?> | |
| <li><a href="/publish">Publish New Article</a></li> | |
| <?php } ?> | |
| ... | |
| </ol> |