© 2026 LinearBytes Inc.
Search posts, tags, users, and pages
Biplab Malakar
Senior Software Engineer, JavaScript Developer, MEAN Developer, Node.js Developer, MERN Developer, Hybrid Mobile App Developer and ML Develo
Before moving to details, I just want to give some overview about JavaScript Object JavaScript object are collection of key->value pairs, we all know about that. But the power of JavaScript Object is JavaScript Object are the actual implementation o...
Abhishek Singh
Learner
Nice observation. Good. But what about default case?
Thats the issue, you can't define any default case. It will return 'undefined' if case not found. Or, you can do
function getVal(key){ return { 'a': 1, 'b': 2 }[key] || -1 }
getVal('c') // -1
if key not found then always return -1
Abhishek Singh
Learner
Nice observation. Good. But what about default case?