ifFail()

Tests subject against control and if it results in a false-ish value falsyValue will be passed back. Otherwise, if opt_truthyValue is given it will be passed back, but if not subject will be passed back.

This function is valid in v2.8.0 to v2.24.3. This function has been downloaded 61 times.

Parameters

{*} subject
Value to test.
{Function|RegExp} control
If this is a function it will be called with subject being the only argument. Otherwise, this regular expression will be tested against subject.
{*} falsyValue
Value to be returned if testing subject against control results in a false-ish value.
{*=} opt_truthyValue Optional, Default:subject
Value to be returned if testing subject against control results in a true-ish value.

Returns

{*}
falsyValue will be returned if testing subject against control results in a false-ish value. Otherwise, if opt_truthyValue is given it will be returned, but if not given subject will be returned.

Required Function

This function directly requires the following function which is included automatically:

  • ifIs()
    If the first and second arguments are the same the third argument is passed back, otherwise the fourth argument (or if not given the first argument) is passed back.

Requiring Function

This function is directly required by the following function:

  • ifIs()
    If the first and second arguments are the same the third argument is passed back, otherwise the fourth argument (or if not given the first argument) is passed back.