Like Seth’s answer, but uses Object.keys()
instead:
const varToString = varObj => Object.keys(varObj)[0]
const someVar = 42
const displayName = varToString({ someVar })
console.log(displayName)
More Related Contents:
- Javascript unknown error
- jquery get id of input selected text
- How does basic object/function chaining work in javascript?
- Open URL in new window with JavaScript
- Alternative to a million IF statements
- Set custom HTML5 required field validation message
- How is Javascript single threaded?
- jQuery $(“#radioButton”).change(…) not firing during de-selection
- moment.js – UTC gives wrong date
- Styling [duplicate]
- Force browser to refresh CSS, JavaScript, etc
- What is the meaning of an Underscore in javascript function parameter?
- Client Routing (using react-router) and Server-Side Routing
- pure javascript to check if something has hover (without setting on mouseover/out)
- Where is d3.svg.diagonal()?
- Custom exception type
- Angular 2 Material 2 datepicker date format
- Getting the value from a TinyMCE textarea
- Create a hidden field in JavaScript
- Put a Delay in Javascript
- Replace function not replacing [duplicate]
- In AngularJS, any inline javascript code that included in HTML templates doesn’t work
- Is it possible to add html inside a title attribute?
- jQuery Datepicker: Prevent closing picker when clicking a date
- Include Arabic characters in JavaScript regular expression?
- How to set custom validation messages for HTML forms?
- Pass a variable from content script to popup
- Use RegExp to match a parenthetical number then increment it
- Select2() is not a function
- How do I put this on Real-Time? I already put (async: True) but it doesnt work