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 skillSet = new Array(); | |
| skillSet['Document language'] = 'HTML5'; | |
| skillSet['Styling language'] = 'CSS3'; | |
| skillSet['Javascript library'] = 'jQuery'; | |
| skillSet['Other'] = 'Usability and accessibility'; | |
| //short hand version | |
| var skillSet = { | |
| 'Document language' : 'HTML5', | |
| 'Styling language' : 'CSS3', |
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; | |
| var y; | |
| var z = 3; | |
| //shorthand | |
| var x, y, z=3; |
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
| x=x+1; | |
| minusCount = minusCount - 1; | |
| y=y*10; | |
| //shorthand version | |
| x++; | |
| minusCount --; | |
| y*=10; | |
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 (likeJavaScript == true) | |
| //shorthand | |
| if (likeJavaScript) | |
| //another version | |
| var a; | |
| if ( a != true ) { | |
| // 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
| function myFunction( myString, myNumber, myObject, myArray, myBoolean ) { | |
| // do something... | |
| } | |
| myFunction( "String", 1, [], {}, true ); | |
| //shorthand | |
| function myFunction() { | |
| console.log( arguments.length ); // Returns 5 | |
| for ( i = 0; i < arguments.length; 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
| for (var i = 0; i < allImgs.length; i++) | |
| //shorthand | |
| for(var i in allImgs) | |
| //with array | |
| function logArrayElements(element, index, array) { | |
| console.log("a[" + index + "] = " + element); | |
| } | |
| [2, 5, 9].forEach(logArrayElements); |
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
| "myString".charAt(0); | |
| //shorthand | |
| "myString"[0]; // Returns 'm' |
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
| switch (something) { | |
| case 1: | |
| doX(); | |
| break; | |
| case 2: | |
| doY(); | |
| break; | |
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 i=0; | |
| while (i<9) | |
| { | |
| //do stuff | |
| i++; //say | |
| } | |
| //shorthand | |
| var i=9; |
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( myvar==1 || myvar==5 || myvar==7 || myvar==22 ) alert('yeah') | |
| //shorthand | |
| if([1,5,7,22].indexOf(myvar)!=-1) alert('yeah baby!') |