KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
var tr={}; tr.SomeThing='SomeThingElse'; console.log(tr.SomeThing); // SomeThingElse console.log(tr.Other); // undefined tr.get=function(what){ if (tr.hasOwnProperty(what)) return tr[what]; else return what; }; tr.get('SomeThing') // SomeThingElse tr.get('Other') // Other Is there any way to make tr.Other or tr['Other'] and all other undefined properties of the object to return its name instead undefined?
Tags (comma-separated)
Save Edits
Cancel