0

How can I get a handle to "[[PromiseValue]]"?

I tried "a[[PromiseValue]]"

enter image description here

purplerice
  • 473
  • 1
  • 6
  • 22
  • 2
    You want to have a look at [this question](http://stackoverflow.com/questions/28916710/what-does-promisevalue-mean-in-javascript-console-and-how-to-do-i-get-it). – halfbit Aug 15 '15 at 11:50

1 Answers1

1

This is nothing to do with arrays. [[PromiseValue]] is the name of the property.

It's an internal property of the promise object you shouldn't access directly (if you even can, which I doubt). If you could, it would be with brackets notation and a string:

a["[[PromiseValue]]"]

...but again, you shouldn't do that (if you even can I checked, and you can't). Instead, use then to get notification when the promise has been settled, and to receive its value:

a.then(function(value) {
    // ...
});

Example:

var a = new Promise(function(resolve) {
  resolve("Hi"); // <== Settles the promise and sets its value
});
a.then(function(value) {
  snippet.log(value); // Using the value
});
<!-- Script provides the `snippet` object, see http://meta.stackexchange.com/a/242144/134069 -->
<script src="http://tjcrowder.github.io/simple-snippets-console/snippet.js"></script>
T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875