codereadability.com/javascript-default-parameters-with-or-operator

If you’re working with JavaScript I’m sure you’ve seen code that uses the OR operator (||) like this: function eatFruit (fruit) { fruit = fruit || "strawberry"; ... } What does this do? It sets a default value! When the function is called...


Comments (0)

Sign in to post comments.