javascript very basic.
-
variables
var varString = "abc"; var varNumber = 123; var varArray = ["abc",123];
-
function
var varFunction = function () { code code code; };
-
control flow
// if-else if (condition) { code code code; } else if { code code code; } else { code code code; } //while while (condition) { code code code; } //do-while do { code code code; } while (condition) //for for (initial ; condition ; incrementor) { code code code; }
-
Math
var NumberSeven = Math.floor(7.14); var RandomBetweenZeroAndOne = Math.randome(); //A random number between 1 and 10 var randomNumber = Math.floor(Math.random() * 9 + 1);
-
oo
//Literal notation var varObject = function () { this.property1= property1; this.property2 = property2; this.method = function () { code code code; code code code; } }; //Constructor notation var varObject = new Object(); varObject.property1 = property1; varObject.property2 = property2; varObject.method = function () { code code code; code code code; }
Written by Chao YANG
Related protips
1 Response
@marti1125
Thanks,
I am learning how to code javascript @ http://www.codecademy.com, it rocks.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Related Tags
#javascript
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#