hmu332233 / tips

https://tips.minung.dev
1 stars 0 forks source link

Method parameter validation #12

Open hmu332233 opened 4 years ago

hmu332233 commented 4 years ago

Search Keyword is, required

hmu332233 commented 2 years ago
const isRequired = () => { throw new Error('param is required'); };
const print = (num = isRequired()) => { console.log(`printing ${num}`) };
print(2);//printing 2
print()// error
print(null)//printing null