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
| //FightCode can only understand your robot | |
| //if its class is called Robot | |
| var Robot = function(robot) { | |
| }; | |
| Robot.prototype.onIdle = function(ev) { | |
| var robot = ev.robot; | |
| robot.ahead(100); |
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 (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () { | |
| var Storage = function (type) { | |
| function createCookie(name, value, days) { | |
| var date, expires; | |
| if (days) { | |
| date = new Date(); | |
| date.setTime(date.getTime()+(days*24*60*60*1000)); | |
| expires = "; expires="+date.toGMTString(); |
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
| // older way in jquery | |
| $('ul').delegate('li','click',function(){ | |
| // do something | |
| }); | |
| //newer way | |
| $("ul").on("click","li",function(){ | |
| // do something | |
| }); |
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 employees = [ | |
| { | |
| "firstName": "John", | |
| "lastName": "Doe" | |
| }, | |
| { | |
| "firstName": "Anna", | |
| "lastName": "Smith" | |
| }, | |
| { |
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 person ={ | |
| "employee":{ | |
| "name": "Mohit Seth", | |
| "role": "Javascript Developer" | |
| } | |
| } | |
| /*this should be avoided*/ |
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 should be avoided | |
| <script> | |
| // block A javascript code | |
| </script> | |
| <script> | |
| //block B javascript code | |
| </script> |
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 should be avoided */ | |
| <input type="button" id="click-button" onclick="doSomething();" /> | |
| /* Better way to add javascript */ | |
| <input type="button" id="click-button" /> | |
| <script> |
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 is a global variable*/ | |
| var name = "Mohit Seth"; | |
| var role = "UI Developer"; | |
| /*It is how namespacing can be done*/ | |
| var NS = { | |
| name: "Mohit Seth", | |
| role: "UI Developer" |
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 Logger = { | |
| log : function( msg ) { | |
| if( console ) { | |
| console.log(msg); | |
| } | |
| } | |
| }; |
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
| <script> | |
| document.domain="parentdomain.com"; | |
| </script> |