Creates a new object from the combination of two or more objects.

Use Array.prototype.reduce() combined with Object.keys(obj) to iterate over all objects and keys.
Use hasOwnProperty() and Array.prototype.concat() to append values for keys existing in multiple objects.

继续阅读 30秒学会 JavaScript 片段 – merge

Add special characters to text to print in color in the console (combined with console.log()).

Use template literals and special characters to add the appropriate color code to the string output.
For background colors, add a special character that resets the background color at the end of the string.

继续阅读 30秒学会 JavaScript 片段 – colorize

Removes zero values from a collection.

Use reflect.ValueOf() to get the array or slice, make() to make an appropriate slice.
Use a for loop with Value.Len() and Value.Index() to iterate over each element.
Use append() to add it to the resulting slice if Value.IsZero() is `false.

继续阅读 30秒学会 Golang 片段 – Compact

Under the hood Angular compiles structural directives into ng-template elements, e.g.:

<!-- This -->
<div *ngFor="let item of [1,2,3]">

<!-- Get expanded into this -->
<ng-template ngFor [ngForOf]="[1,2,3]" let-item="$implicit"></ng-template>

The value passed to *ngFor directive is written using microsyntax. You can learn about it in the docs.

Also check out an interactive tool that shows the expansion by Alexey Zuev

翻译自:https://www.30secondsofcode.org/angular/s/understanding-microsyntax

相关链接

Returns a customized coalesce function that returns the first argument that returns true from the provided argument validation function.

Use Array.prototype.find() to return the first argument that returns true from the provided argument validation function.

继续阅读 30秒学会 JavaScript 片段 – coalesceFactory