Reputation: 1
I have an object named promise and it has functions and string inside it. For printing the object i can use
console.log(promise);
but i have a string named "responseText"
inside promise. If i try to print it using
console.log(promise.responseText);
,its showing as undefined. I can see the value of responseText by printing the object. But when i print using promise.responseText
its showing undefined.
FYI
I am able to print all the functions
inside promise
, but I am not able to print the string. Please help.
Upvotes: 0
Views: 89
Reputation: 66
Use
var promise = {
responseText: function(){
return "responseText"
}
}
console.log(promise.responseText())
OR
var promise = {
responseText: function(){
console.log("responseText")
}
}
promise.responseText()
Upvotes: 2