Can't perform any operations over object in javascript The 2019 Stack Overflow Developer Survey Results Are InLength of a JavaScript objectWhat is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?How do I check if an array includes an object in JavaScript?Which equals operator (== vs ===) should be used in JavaScript comparisons?How do I test for an empty JavaScript object?How do I correctly clone a JavaScript object?What is the !! (not not) operator in JavaScript?Checking if a key exists in a JavaScript object?How to use foreach with array in JavaScript?
Worn-tile Scrabble
Am I thawing this London Broil safely?
Output the Arecibo Message
Why is the maximum length of OpenWrt’s root password 8 characters?
Why do UK politicians seemingly ignore opinion polls on Brexit?
What do hard-Brexiteers want with respect to the Irish border?
Protecting Dualbooting Windows from dangerous code (like rm -rf)
When should I buy a clipper card after flying to OAK?
Why do we hear so much about the Trump administration deciding to impose and then remove tariffs?
Loose spokes after only a few rides
Why didn't the Event Horizon Telescope team mention Sagittarius A*?
If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?
What is the accessibility of a package's `Private` context variables?
Can a rogue use sneak attack with weapons that have the thrown property even if they are not thrown?
What do the Banks children have against barley water?
Return to UK after being refused entry years previously
How to manage monthly salary
Did 3000BC Egyptians use meteoric iron weapons?
Lightning Grid - Columns and Rows?
Is three citations per paragraph excessive for undergraduate research paper?
Resizing object distorts it (Illustrator CC 2018)
Shouldn't "much" here be used instead of "more"?
How to save as into a customized destination on macOS?
Can you compress metal and what would be the consequences?
Can't perform any operations over object in javascript
The 2019 Stack Overflow Developer Survey Results Are InLength of a JavaScript objectWhat is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?How do I check if an array includes an object in JavaScript?Which equals operator (== vs ===) should be used in JavaScript comparisons?How do I test for an empty JavaScript object?How do I correctly clone a JavaScript object?What is the !! (not not) operator in JavaScript?Checking if a key exists in a JavaScript object?How to use foreach with array in JavaScript?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have two functions as given below. getRawData() and getBTRawData()
- getBTRawData() just gets the data from Bluetooth from a phone
- getRawData() gets the return value from getBTRawData() and tries to iterate over but that doesn't seem to work. I'm able to print the value inside a promise but I can't perform any functions on it.
getRawData()
const result = this.getBTRawData().then((item) =>
console.log("Item in this one: ", item);
let flatten = [];
for(let i in item)
console.log("something here");
flatten.push(...item[i]);
console.log(flatten);
).catch(err =>
console.log(err);
);
async getBTRawData()
let result = [];
const res = await this.bluetoothSerial.subscribeRawData().subscribe((data) =>
//console.log("raw data");
// console.log(data);
var buffer = new Uint8Array(data);
//this.raw_data_c.push(buffer);
result.push(buffer);
//console.log(this.raw_data_c);).map(
// console.log(result);
);
return result;
Any help is greatly appreciated. Thank you.
javascript
|
show 4 more comments
I have two functions as given below. getRawData() and getBTRawData()
- getBTRawData() just gets the data from Bluetooth from a phone
- getRawData() gets the return value from getBTRawData() and tries to iterate over but that doesn't seem to work. I'm able to print the value inside a promise but I can't perform any functions on it.
getRawData()
const result = this.getBTRawData().then((item) =>
console.log("Item in this one: ", item);
let flatten = [];
for(let i in item)
console.log("something here");
flatten.push(...item[i]);
console.log(flatten);
).catch(err =>
console.log(err);
);
async getBTRawData()
let result = [];
const res = await this.bluetoothSerial.subscribeRawData().subscribe((data) =>
//console.log("raw data");
// console.log(data);
var buffer = new Uint8Array(data);
//this.raw_data_c.push(buffer);
result.push(buffer);
//console.log(this.raw_data_c);).map(
// console.log(result);
);
return result;
Any help is greatly appreciated. Thank you.
javascript
Not sure what could be going wrong...I stubbedgetBTRawDatato resolve to an array ofUint8Array's and getBTRawData worked fine
– brian-lives-outdoors
Mar 22 at 4:15
yea, getBTRawData does return an array of Uint8Arrays but I can't loop over the result, which I don't understand why
– Abubakar Saad
Mar 22 at 4:23
What happens? Can you see thatitemis an array ofUint8Arrays in thethencallback? (Does yourconsole.log("Item in this one: ", item);print anything?)
– brian-lives-outdoors
Mar 22 at 4:25
(oh, and my bad...I meant to saygetRawData worked finein my first comment)
– brian-lives-outdoors
Mar 22 at 4:28
yea, it prints Array of Uint8Arrays but I can't seem to loop over. The loop won't execute at all.
– Abubakar Saad
Mar 22 at 4:30
|
show 4 more comments
I have two functions as given below. getRawData() and getBTRawData()
- getBTRawData() just gets the data from Bluetooth from a phone
- getRawData() gets the return value from getBTRawData() and tries to iterate over but that doesn't seem to work. I'm able to print the value inside a promise but I can't perform any functions on it.
getRawData()
const result = this.getBTRawData().then((item) =>
console.log("Item in this one: ", item);
let flatten = [];
for(let i in item)
console.log("something here");
flatten.push(...item[i]);
console.log(flatten);
).catch(err =>
console.log(err);
);
async getBTRawData()
let result = [];
const res = await this.bluetoothSerial.subscribeRawData().subscribe((data) =>
//console.log("raw data");
// console.log(data);
var buffer = new Uint8Array(data);
//this.raw_data_c.push(buffer);
result.push(buffer);
//console.log(this.raw_data_c);).map(
// console.log(result);
);
return result;
Any help is greatly appreciated. Thank you.
javascript
I have two functions as given below. getRawData() and getBTRawData()
- getBTRawData() just gets the data from Bluetooth from a phone
- getRawData() gets the return value from getBTRawData() and tries to iterate over but that doesn't seem to work. I'm able to print the value inside a promise but I can't perform any functions on it.
getRawData()
const result = this.getBTRawData().then((item) =>
console.log("Item in this one: ", item);
let flatten = [];
for(let i in item)
console.log("something here");
flatten.push(...item[i]);
console.log(flatten);
).catch(err =>
console.log(err);
);
async getBTRawData()
let result = [];
const res = await this.bluetoothSerial.subscribeRawData().subscribe((data) =>
//console.log("raw data");
// console.log(data);
var buffer = new Uint8Array(data);
//this.raw_data_c.push(buffer);
result.push(buffer);
//console.log(this.raw_data_c);).map(
// console.log(result);
);
return result;
Any help is greatly appreciated. Thank you.
getRawData()
const result = this.getBTRawData().then((item) =>
console.log("Item in this one: ", item);
let flatten = [];
for(let i in item)
console.log("something here");
flatten.push(...item[i]);
console.log(flatten);
).catch(err =>
console.log(err);
);
async getBTRawData()
let result = [];
const res = await this.bluetoothSerial.subscribeRawData().subscribe((data) =>
//console.log("raw data");
// console.log(data);
var buffer = new Uint8Array(data);
//this.raw_data_c.push(buffer);
result.push(buffer);
//console.log(this.raw_data_c);).map(
// console.log(result);
);
return result;
getRawData()
const result = this.getBTRawData().then((item) =>
console.log("Item in this one: ", item);
let flatten = [];
for(let i in item)
console.log("something here");
flatten.push(...item[i]);
console.log(flatten);
).catch(err =>
console.log(err);
);
async getBTRawData()
let result = [];
const res = await this.bluetoothSerial.subscribeRawData().subscribe((data) =>
//console.log("raw data");
// console.log(data);
var buffer = new Uint8Array(data);
//this.raw_data_c.push(buffer);
result.push(buffer);
//console.log(this.raw_data_c);).map(
// console.log(result);
);
return result;
javascript
javascript
edited Mar 22 at 3:46
Abubakar Saad
asked Mar 22 at 3:39
Abubakar SaadAbubakar Saad
73110
73110
Not sure what could be going wrong...I stubbedgetBTRawDatato resolve to an array ofUint8Array's and getBTRawData worked fine
– brian-lives-outdoors
Mar 22 at 4:15
yea, getBTRawData does return an array of Uint8Arrays but I can't loop over the result, which I don't understand why
– Abubakar Saad
Mar 22 at 4:23
What happens? Can you see thatitemis an array ofUint8Arrays in thethencallback? (Does yourconsole.log("Item in this one: ", item);print anything?)
– brian-lives-outdoors
Mar 22 at 4:25
(oh, and my bad...I meant to saygetRawData worked finein my first comment)
– brian-lives-outdoors
Mar 22 at 4:28
yea, it prints Array of Uint8Arrays but I can't seem to loop over. The loop won't execute at all.
– Abubakar Saad
Mar 22 at 4:30
|
show 4 more comments
Not sure what could be going wrong...I stubbedgetBTRawDatato resolve to an array ofUint8Array's and getBTRawData worked fine
– brian-lives-outdoors
Mar 22 at 4:15
yea, getBTRawData does return an array of Uint8Arrays but I can't loop over the result, which I don't understand why
– Abubakar Saad
Mar 22 at 4:23
What happens? Can you see thatitemis an array ofUint8Arrays in thethencallback? (Does yourconsole.log("Item in this one: ", item);print anything?)
– brian-lives-outdoors
Mar 22 at 4:25
(oh, and my bad...I meant to saygetRawData worked finein my first comment)
– brian-lives-outdoors
Mar 22 at 4:28
yea, it prints Array of Uint8Arrays but I can't seem to loop over. The loop won't execute at all.
– Abubakar Saad
Mar 22 at 4:30
Not sure what could be going wrong...I stubbed
getBTRawData to resolve to an array of Uint8Array's and getBTRawData worked fine– brian-lives-outdoors
Mar 22 at 4:15
Not sure what could be going wrong...I stubbed
getBTRawData to resolve to an array of Uint8Array's and getBTRawData worked fine– brian-lives-outdoors
Mar 22 at 4:15
yea, getBTRawData does return an array of Uint8Arrays but I can't loop over the result, which I don't understand why
– Abubakar Saad
Mar 22 at 4:23
yea, getBTRawData does return an array of Uint8Arrays but I can't loop over the result, which I don't understand why
– Abubakar Saad
Mar 22 at 4:23
What happens? Can you see that
item is an array of Uint8Arrays in the then callback? (Does your console.log("Item in this one: ", item); print anything?)– brian-lives-outdoors
Mar 22 at 4:25
What happens? Can you see that
item is an array of Uint8Arrays in the then callback? (Does your console.log("Item in this one: ", item); print anything?)– brian-lives-outdoors
Mar 22 at 4:25
(oh, and my bad...I meant to say
getRawData worked fine in my first comment)– brian-lives-outdoors
Mar 22 at 4:28
(oh, and my bad...I meant to say
getRawData worked fine in my first comment)– brian-lives-outdoors
Mar 22 at 4:28
yea, it prints Array of Uint8Arrays but I can't seem to loop over. The loop won't execute at all.
– Abubakar Saad
Mar 22 at 4:30
yea, it prints Array of Uint8Arrays but I can't seem to loop over. The loop won't execute at all.
– Abubakar Saad
Mar 22 at 4:30
|
show 4 more comments
1 Answer
1
active
oldest
votes
getBTRawData seems to be returning an array, not a Promise. You should be able to directly work with the data from getBTRawData inside getRawData (assuming everything else works).
I've changed that but when I try to flatten it, it returns empty array and console for the result becomes object: __zone_symbol__state: true __zone_symbol__value: Array(52) 0: Uint8Array [84] 1: Uint8Array(5) [82, 85, 69, 13, 10]
– Abubakar Saad
Mar 22 at 4:27
It seems like you just need to get rid of those__zone_symbol__*keys in the object and then you should be able to iterate over it
– miyu
Mar 22 at 4:36
but ____zone_symbol__* is basically indicating its promise, right?
– Abubakar Saad
Mar 22 at 4:38
Not too sure about the details of your bluetooth library, so you might be right in which case I don't really know whats happening, sorry! If you print the data in__zone_symbol__valueis it what you expect at least?
– miyu
Mar 22 at 4:45
No worries, thanks for the help. Yes, the data is exactly what I expect.
– Abubakar Saad
Mar 22 at 4:49
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55292546%2fcant-perform-any-operations-over-object-in-javascript%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
getBTRawData seems to be returning an array, not a Promise. You should be able to directly work with the data from getBTRawData inside getRawData (assuming everything else works).
I've changed that but when I try to flatten it, it returns empty array and console for the result becomes object: __zone_symbol__state: true __zone_symbol__value: Array(52) 0: Uint8Array [84] 1: Uint8Array(5) [82, 85, 69, 13, 10]
– Abubakar Saad
Mar 22 at 4:27
It seems like you just need to get rid of those__zone_symbol__*keys in the object and then you should be able to iterate over it
– miyu
Mar 22 at 4:36
but ____zone_symbol__* is basically indicating its promise, right?
– Abubakar Saad
Mar 22 at 4:38
Not too sure about the details of your bluetooth library, so you might be right in which case I don't really know whats happening, sorry! If you print the data in__zone_symbol__valueis it what you expect at least?
– miyu
Mar 22 at 4:45
No worries, thanks for the help. Yes, the data is exactly what I expect.
– Abubakar Saad
Mar 22 at 4:49
add a comment |
getBTRawData seems to be returning an array, not a Promise. You should be able to directly work with the data from getBTRawData inside getRawData (assuming everything else works).
I've changed that but when I try to flatten it, it returns empty array and console for the result becomes object: __zone_symbol__state: true __zone_symbol__value: Array(52) 0: Uint8Array [84] 1: Uint8Array(5) [82, 85, 69, 13, 10]
– Abubakar Saad
Mar 22 at 4:27
It seems like you just need to get rid of those__zone_symbol__*keys in the object and then you should be able to iterate over it
– miyu
Mar 22 at 4:36
but ____zone_symbol__* is basically indicating its promise, right?
– Abubakar Saad
Mar 22 at 4:38
Not too sure about the details of your bluetooth library, so you might be right in which case I don't really know whats happening, sorry! If you print the data in__zone_symbol__valueis it what you expect at least?
– miyu
Mar 22 at 4:45
No worries, thanks for the help. Yes, the data is exactly what I expect.
– Abubakar Saad
Mar 22 at 4:49
add a comment |
getBTRawData seems to be returning an array, not a Promise. You should be able to directly work with the data from getBTRawData inside getRawData (assuming everything else works).
getBTRawData seems to be returning an array, not a Promise. You should be able to directly work with the data from getBTRawData inside getRawData (assuming everything else works).
answered Mar 22 at 3:47
miyumiyu
2347
2347
I've changed that but when I try to flatten it, it returns empty array and console for the result becomes object: __zone_symbol__state: true __zone_symbol__value: Array(52) 0: Uint8Array [84] 1: Uint8Array(5) [82, 85, 69, 13, 10]
– Abubakar Saad
Mar 22 at 4:27
It seems like you just need to get rid of those__zone_symbol__*keys in the object and then you should be able to iterate over it
– miyu
Mar 22 at 4:36
but ____zone_symbol__* is basically indicating its promise, right?
– Abubakar Saad
Mar 22 at 4:38
Not too sure about the details of your bluetooth library, so you might be right in which case I don't really know whats happening, sorry! If you print the data in__zone_symbol__valueis it what you expect at least?
– miyu
Mar 22 at 4:45
No worries, thanks for the help. Yes, the data is exactly what I expect.
– Abubakar Saad
Mar 22 at 4:49
add a comment |
I've changed that but when I try to flatten it, it returns empty array and console for the result becomes object: __zone_symbol__state: true __zone_symbol__value: Array(52) 0: Uint8Array [84] 1: Uint8Array(5) [82, 85, 69, 13, 10]
– Abubakar Saad
Mar 22 at 4:27
It seems like you just need to get rid of those__zone_symbol__*keys in the object and then you should be able to iterate over it
– miyu
Mar 22 at 4:36
but ____zone_symbol__* is basically indicating its promise, right?
– Abubakar Saad
Mar 22 at 4:38
Not too sure about the details of your bluetooth library, so you might be right in which case I don't really know whats happening, sorry! If you print the data in__zone_symbol__valueis it what you expect at least?
– miyu
Mar 22 at 4:45
No worries, thanks for the help. Yes, the data is exactly what I expect.
– Abubakar Saad
Mar 22 at 4:49
I've changed that but when I try to flatten it, it returns empty array and console for the result becomes object: __zone_symbol__state: true __zone_symbol__value: Array(52) 0: Uint8Array [84] 1: Uint8Array(5) [82, 85, 69, 13, 10]
– Abubakar Saad
Mar 22 at 4:27
I've changed that but when I try to flatten it, it returns empty array and console for the result becomes object: __zone_symbol__state: true __zone_symbol__value: Array(52) 0: Uint8Array [84] 1: Uint8Array(5) [82, 85, 69, 13, 10]
– Abubakar Saad
Mar 22 at 4:27
It seems like you just need to get rid of those
__zone_symbol__* keys in the object and then you should be able to iterate over it– miyu
Mar 22 at 4:36
It seems like you just need to get rid of those
__zone_symbol__* keys in the object and then you should be able to iterate over it– miyu
Mar 22 at 4:36
but ____zone_symbol__* is basically indicating its promise, right?
– Abubakar Saad
Mar 22 at 4:38
but ____zone_symbol__* is basically indicating its promise, right?
– Abubakar Saad
Mar 22 at 4:38
Not too sure about the details of your bluetooth library, so you might be right in which case I don't really know whats happening, sorry! If you print the data in
__zone_symbol__value is it what you expect at least?– miyu
Mar 22 at 4:45
Not too sure about the details of your bluetooth library, so you might be right in which case I don't really know whats happening, sorry! If you print the data in
__zone_symbol__value is it what you expect at least?– miyu
Mar 22 at 4:45
No worries, thanks for the help. Yes, the data is exactly what I expect.
– Abubakar Saad
Mar 22 at 4:49
No worries, thanks for the help. Yes, the data is exactly what I expect.
– Abubakar Saad
Mar 22 at 4:49
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55292546%2fcant-perform-any-operations-over-object-in-javascript%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Not sure what could be going wrong...I stubbed
getBTRawDatato resolve to an array ofUint8Array's and getBTRawData worked fine– brian-lives-outdoors
Mar 22 at 4:15
yea, getBTRawData does return an array of Uint8Arrays but I can't loop over the result, which I don't understand why
– Abubakar Saad
Mar 22 at 4:23
What happens? Can you see that
itemis an array ofUint8Arrays in thethencallback? (Does yourconsole.log("Item in this one: ", item);print anything?)– brian-lives-outdoors
Mar 22 at 4:25
(oh, and my bad...I meant to say
getRawData worked finein my first comment)– brian-lives-outdoors
Mar 22 at 4:28
yea, it prints Array of Uint8Arrays but I can't seem to loop over. The loop won't execute at all.
– Abubakar Saad
Mar 22 at 4:30