if2
if2 A,B := if A then A else B
Table Of Contents
Links
Get Started
var if2 = ; ;// RETURN 1 ;// RETURN true ;// RETURN 3 ;// RETURN undefined
API
Basic
-
if2(...)
Return the first argument which is truthy。
Read Truthy and Falsy: When All is Not Equal in JavaScript for more. -
if2.satisfies( Function judger, ... )
Return the first remainder argument which satisfies the judger.
This method may be curried. If only one argument passed, it will return something like function satisfiesJudger. -
if2.is( Function proto, ... )
Return the first remainder argument which is an instance of proto.
This method may be curried. If only one argument passed, it will return something like function isInstanceOfProto. -
if2.assignIfHasnot( Object foo, string propertyName, ANY value )
Assign specified property of the object if it has not such property.
Predefined Methods
For convenience, some frequently-used judger is predfined. The usage of following methods is self-evident.
- if2.array(...)
- if2.boolean(...)
- if2.defined(...)
- if2.function(...)
- if2.number(...)
- if2.string(...)
Examples
if2 can be used with other type testing library such as is. E.g.
const if2 = ;const is = ; if2;// RETURN 4