Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let sober = true;
- let isSober = () => {
- console.log('This person is completely sober.');
- }
- let isDrunk = () => {
- console.log('This person had too much alcohol.');
- }
- // A normal if statement
- if(sober) isSober(); // This person is completely sober.
- // Above can be done using '&&' operator
- sober && isSober(); // This person is completely sober.
- // Using logical OR - '||' operator
- sober = false;
- // A normal if statement
- if(!sober) isDrunk(); // This person had too much alcohol.
- sober || isDrunk(); // This person had too much alcohol.
- // In this specific example, the logical OR could also be used to set a defalt value
- const getBio = (name, year, breed) => {
- name = name || 'John';
- year = year || 2018;
- breed = breed || 'Beagle';
- }
Add Comment
Please, Sign In to add comment