0

I have this array which when there is only one item left in the array, causes the array to be set to undefined.

Basically, this:

var array = {"example"}

To do this I say this:

if (array[1] == NULL){
    compiled = undefined;
}
info.add('assignment', compiled);
info.save(null, {
success:function(){//Whatever};

The problem is that parse does not update the object with the value undefined.

Any help?

4
  • What does this have to do with parsing? Did you mean parse.com? If so, how is that involved? Commented Dec 3, 2015 at 21:56
  • This is parse.com, sorry for not being clear enough, I thought parse idk was enough. Parse.com is used as my back end server to handle all user information, such as login, and other stuff. Parse holds the array that I am using. Commented Dec 3, 2015 at 22:02
  • your var array isn't an array, by the way Commented Dec 3, 2015 at 22:55
  • I fixed your tag. Next time, please use the parse.com tag; parsing has a different purpose. I know little about parse.com, but I don't see how a back-end service can "hold" a javascript array; the array is in the javascript engine. The original data may well be on the back-end server, but the issue you have seems to be entirely local. Of course, it is 100% possible that I'm missing something. Commented Dec 3, 2015 at 22:56

3 Answers 3

4

I faced the problem and made the research, here to share.

The problem is that parse does not update the object with the value undefined.

Using unset() can clear the property of parse object, and then use save() to update property. Here is the document : Parse Object

In your use case, would be like ...

let array = ["example"]

if (array[1] == NULL) {
  info.unset('assignment'); //set assignment to undefined
}
else {
  //Other way to set assignment property
}
info.save(null, { success: function() { //Whatever };

Hope this will help.

Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

Change this if statement:

if (array[1] == NULL){
  compiled = undefined;
}

TO this:

if(array.length > 1){
  compiled = undefined;
}

Comments

0

I have figured out the answer to my own question.

Basically, Parse has a function to unset an array to undefined.

I unset the parse array, then save it,

If my local array is not null, then I update the local array to the parse array.

I will provide code if anyone needs help!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.