LexarG56

Generation

generate functionSun, 18 Jun 2023

Hacer que un caso default regrese a la tarea anterior

// Para objetos function foo(input) { // do something with the input return input } var result = foo(123) // result is 123 var result2 = foo() // result is undefined // Para strings function bar(input) { return input || 'default value' } var result3 = bar(123) // result is 123 var result4 = bar() // result is 'default value' // Para numbers function baz(input) { return input !== undefined ? input : 0 } var result5 = baz(123) // result is 123 var result6 = baz() // result is 0

Questions about programming?Chat with your personal AI assistant