repl.txt (830B)
1 2 {{alias}}( x, y ) 3 If a function does not throw, returns the function return value; otherwise, 4 returns the value returned by a second function `y`. 5 6 The function `y` is provided a single argument: 7 8 - error: the error thrown by `x` 9 10 Parameters 11 ---------- 12 x: Function 13 Function to try invoking. 14 15 y: Function 16 Function to invoke if an initial function throws an error. 17 18 Returns 19 ------- 20 z: any 21 The return value of either `x` or `y`. 22 23 Examples 24 -------- 25 > function x() { 26 ... if ( {{alias:@stdlib/random/base/randu}}() < 0.5 ) { 27 ... throw new Error( 'beep' ); 28 ... } 29 ... return 1.0; 30 ... }; 31 > function y() { 32 ... return -1.0; 33 ... }; 34 > var z = {{alias}}( x, y ) 35 <number> 36 37 See Also 38 -------- 39