Tutorial by Examples

Woocommerce is a plugin for WordPress and can be installed like any other WordPress plugin. WooCommerce can only be installed on self hosted installations of WordPress, it cannot be installed onto a site hosted by the wordpress.com service. If you don't have WordPress installed for your website, fo...
A while loop will evaluate its condition, and if true, it will execute the code inside and start over. That is, as long as its condition evaluates to true, the while loop will execute over and over. This loop will execute 100 times, each time adding 1 to the variable num: int num = 0; while (nu...

For

for loops are simplified syntax for a very common loop pattern, which could be accomplished in more lines with a while loop. The following is a common example of a for loop, which will execute 100 times and then stop. for (int i = 0; i < 100; i++) { // do something } This is equivalen...
A do while loop is the same as a while loop, except that it is guaranteed to execute at least one time. The following loop will execute 100 times. int i = 0; do { i++; } while (i < 100); A similar loop, but with a different condition, will execute 1 time. int i = 0; do { i++; ...
There are some ways to break or change a loop's flow. break; will exit the current loop, and will not execute any more lines within that loop. continue; will not execute any more code within the current iteration of the loop, but will remain in the loop. The following loop will execute 101 times ...
To remove a specific item from the browser Storage (the opposite of setItem) use removeItem localStorage.removeItem("greet"); Example: localStorage.setItem("greet", "hi"); localStorage.removeItem("greet"); console.log( localStorage.getItem("greet...
localStorage, sessionStorage are JavaScript Objects and you can treat them as such. Instead of using Storage Methods like .getItem(), .setItem(), etc… here's a simpler alternative: // Set localStorage.greet = "Hi!"; // Same as: window.localStorage.setItem("greet", "Hi!&qu...
Type casting is done with either the as operator: var chair:Chair = furniture as Chair; Or by wrapping the value in Type(): var chair:Chair = Chair(furniture); If the cast fails with as, the result of that cast is null. If the cast fails by wrapping in Type(), a TypeError is thrown.
Functions are of the type Function: function example():void { } trace(example is Function); // true They can be referenced by other variables with the type Function: var ref:Function = example; ref(); // ref.call(), ref.apply(), etc. And they can be passed in as arguments for parameters wh...
References to class declarations are typed Class: var spriteClass:Class = Sprite; You can use variables typed Class to instantiate instances of that class: var sprite:Sprite = new spriteClass(); This can be useful for passing an argument of type Class to a function that might create and inst...
You can tell the compiler the type of a value by annotating it with :Type: var value:int = 10; // A property "value" of type "int". Function parameters and return types can also be annotated: // This function accepts two ints and returns an int. function sum(a:int, b:int):i...
You can use the is operator to validate whether a value is of a certain type: var sprite:Sprite = new Sprite(); trace(sprite is Sprite); // true trace(sprite is DisplayObject); // true, Sprite inherits DisplayObject trace(sprite is IBitmapDrawable); // true, DisplayObject implements IBitmapDra...
Unfortunately ActionScript 3 does not have a concept of generics, so it follows that there is no way to define a typed array as Array<T>. There is however a special class Vector.<T> which works in a similar way except you must provide a reference to a concrete class when instantiating th...
The C++ approach - new and delete In a language like C++, the application program is responsible for managing the memory used by dynamically allocated memory. When an object is created in the C++ heap using the new operator, there needs to be a corresponding use of the delete operator to dispose o...
ga('create', 'UA-XXXX-Y', {'sampleRate': 5}); Optional. This may only be set in the create method. Specifies what percentage of users should be tracked. This defaults to 100 (no users are sampled out) but large sites may need to use a lower sample rate to stay within Google Analytics processing ...
Before ECMAScript 2015 (ES6), a parameter's default value could be assigned in the following way: function printMsg(msg) { msg = typeof msg !== 'undefined' ? // if a value was provided msg : // then, use that value in the reassignemnt 'Default value for ...
Sometimes we need to change type from Collection<T?> to Collections<T>. In that case, filterNotNull is our solution. val a: List<Int?> = listOf(1, 2, 3, null) val b: List<Int> = a.filterNotNull()
Detailed instructions on getting monogame set up or installed.
3 You can use rem defined by the font-size of your html tag to style elements by setting their font-size to a value of rem and use em inside the element to create elements that scale with your global font-size. HTML: <input type="button" value="Button"> <input type=...
localStorage.length property returns an integer number indicating the number of elements in the localStorage Example: Set Items localStorage.setItem('StackOverflow', 'Documentation'); localStorage.setItem('font', 'Helvetica'); localStorage.setItem('image', 'sprite.svg'); Get length localSto...

Page 361 of 1336