Tutorial by Examples: c

Tail Call Optimisation makes it possible to safely implement recursive loops without concern for call stack overflow or the overhead of a growing frame stack. function indexOf(array, predicate, i = 0) { if (0 <= i && i < array.length) { if (predicate(array[i])) { return...
What if you want to rollback the latest migration i.e recent operation, you can use the awesome rollback command. But remember that this command rolls back only the last migration, which may include multiple migration files php artisan migrate:rollback If you are interested in rolling back all o...
Break and continue statements can be followed by an optional label which works like some kind of a goto statement, resumes execution from the label referenced position for(var i = 0; i < 5; i++){ nextLoop2Iteration: for(var j = 0; j < 5; j++){ if(i == j) break nextLoop2Iteration; ...
console.time() can be used to measure how long a task in your code takes to run. Calling console.time([label]) starts a new timer. When console.timeEnd([label]) is called, the elapsed time, in milliseconds, since the original .time() call is calculated and logged. Because of this behavior, you can ...
When using async await in loops, you might encounter some of these problems. If you just try to use await inside forEach, this will throw an Unexpected token error. (async() => { data = [1, 2, 3, 4, 5]; data.forEach(e => { const i = await somePromiseFn(e); console.log(i); }); ...
/// <summary> /// Gets displayName from DataAnnotations attribute /// </summary> /// <typeparam name="TModel"></typeparam> /// <typeparam name="TProperty"></typeparam> /// <param name="htmlHelper"></param> /// <pa...
/// <summary> /// Creates simple button /// </summary> /// <param name="poHelper"></param> /// <param name="psValue"></param> /// <returns></returns> public static MvcHtmlString SubmitButton(this HtmlHelper poHelper, string ps...
Using the collect() helper, you can easily create new collection instances by passing in an array such as: $fruits = collect(['oranges', 'peaches', 'pears']); If you don't want to use helper functions, you can create a new Collection using the class directly: $fruits = new Illuminate\Support\Co...
Angular has reputation for having awesome bidirectional data binding. By default, Angular continuously synchronizes values bound between model and view components any time data changes in either the model or view component. This comes with a cost of being a bit slow if used too much. This will hav...
AngularJS has digest loop and all your functions in a view and filters are executed every time the digest cycle is run. The digest loop will be executed whenever the model is updated and it can slow down your app (filter can be hit multiple times, before the page is loaded). You should avoid this: ...
Watchers needed for watch some value and detect that this value is changed. After call $watch() or $watchCollection new watcher add to internal watcher collection in current scope. So, what is watcher? Watcher is a simple function, which is called on every digest cycle, and returns some value. An...
NSURL *url = [NSURL URLWithString:@"http://www.example.com/"]; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; // Configure the session here. NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration]; [[s...
Note: You can skip this part if your server uses HTTPS to serve content and jump to Application Setup guide. If your app targets iOS 9 and your server uses HTTPS to serve content, you don’t need to sign the file. If not (e.g. when supporting Handoff on iOS 8), it has to be signed using a SSL certif...
The setup on the app side requires two things: Configuring the app’s entitlement, and enabling the universal links by turning on the Associated Domains capability in the project. Handling Incoming Links in your AppDelegate. 1. Configuring the app’s entitlement, and enabling universal links. ...
Mage::log('My log entry', null, 'mylogfile.log'); This wil log to /var/log/mylogfile.log
A common usecase for the ready() hook is to access the DOM, e.g. to initiate a Javascript plugin, get the dimensions of an element etc. The problem Due to Vue's asynchronous DOM update mechanism, it's not guaranteed that the DOM has been fully updated when the ready() hook is called. This usually ...
PHP provides an alternative syntax for some control structures: if, while, for, foreach, and switch. When compared to the normal syntax, the difference is, that the opening brace is replaced by a colon (:) and the closing brace is replaced by endif;, endwhile;, endfor;, endforeach;, or endswitch;, ...
declare is used to set an execution directive for a block of code. The following directives are recognized: ticks encoding strict_types For instance, set ticks to 1: declare(ticks=1); To enable strict type mode, the declare statement is used with the strict_types declaration: declare(s...
require require is similar to include, except that it will produce a fatal E_COMPILE_ERROR level error on failure. When the require fails, it will halt the script. When the include fails, it will not halt the script and only emit E_WARNING. require 'file.php'; PHP Manual - Control Structures - ...
foreach is a construct, which enables you to iterate over arrays and objects easily. $array = [1, 2, 3]; foreach ($array as $value) { echo $value; } Outputs: 123. To use foreach loop with an object, it has to implement Iterator interface. When you iterate over associative arrays: $arra...

Page 180 of 826