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
@Pipe({ name: "filterFalsy" }) | |
export class FilterFalsyPipe implements PipeTransform { | |
transform<T>(array: T[]): T[] {} | |
} |
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
@Pipe({ name: "filterFalsy" }) | |
export class FilterFalsyPipe implements PipeTransform { | |
transform() {} | |
} |
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
@Pipe({ name: "filterFalsy" }) | |
export class FilterFalsyPipe {} |
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
@Pipe({ name: "filterFalsy" }) | |
export class FilterFalsyPipe implements PipeTransform { | |
transform<T>(array: T[]): T[] { | |
return array.filter(Boolean); | |
} | |
} |
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
<h1>The Awesome filterFalsy Pipe in Action</h1> | |
{{falsyArray | filterFalsy}} |
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
@NgModule({ | |
imports: [BrowserModule, FormsModule], | |
declarations: [AppComponent, FilterFalsyPipe], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule {} |
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
import { Component } from "@angular/core"; | |
@Component({ | |
selector: "my-app", | |
templateUrl: "./app.component.html", | |
styleUrls: ["./app.component.css"] | |
}) | |
export class AppComponent { | |
falsyArray = [false, "No", 0, "more", undefined, "falsy", null, "values", NaN]; | |
} |
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
const getArguments = () => Array.from(arguments); | |
console.log(getArguments(1, 2, 3, 4)); | |
// Output: [ƒ (), Object, Object, "/~/index.js", "/~", Window, Window, Object, ƒ c()] | |
console.log(getArguments("arguments", "is", "cool")); | |
// Output: [ƒ (), Object, Object, "/~/index.js", "/~", Window, Window, Object, ƒ c()] |
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 getArguments() { | |
return Array.from(arguments); | |
} | |
console.log(getArguments(1, 2, 3, 4)); | |
// Output: [1, 2, 3, 4] | |
console.log(getArguments("arguments", "is", "cool")); | |
// Output: ["arguments", "is", "cool"] |
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
const add = (...args) => args.reduce((prev, curr) => prev + curr); | |
console.log(add(1, 2, 3, 4, 5, 6)); | |
// Output: 21 |