uladz
July 14, 2024, 2:47am
1
I have tried:
l.sku = undefined;
// this writes “undefined” into SKU field
l.sku = ‘’;
// this writes empty string to SKU
delete l.sku;
// this does nothing
How can I make l.sku undefined again so typeof l.sku == ‘undefined’ is true?
Please advise, thanks! --vlad.
Neal
July 14, 2024, 2:37pm
2
Have you tried the following???
listing.sku = “”;
listing.useSKU = false;
Neal
uladz
July 14, 2024, 7:51pm
3
Yes, see above. This sets sku as “”, not as undefined value in javascript.
Would listing.sku.isEmpty()
work in the context you’re developing? You could combine it with an undefined
check if you’re worried about that.
Javascript specifically uses undefined
for variables that have never been set. There is no way to make an existing variable undefined
AFAIK.
ilja
July 16, 2024, 7:33pm
5
Not tested, but have you tried:
l.sku = null;
Not sure how Apple’s JavaScript interpreter handles this.
uladz
July 16, 2024, 11:50pm
6
Vaguery:
Would listing.sku.isEmpty()
work in the context you’re developing? You could combine it with an undefined
check if you’re worried about that.
Javascript specifically uses undefined
for variables that have never been set. There is no way to make an existing variable undefined
AFAIK.
Yes, I can check if (typeof listing.sku == ‘undefined’ | listing.sku == ‘’) and it solves the issue. I thought you can actually set a variable as undefined specifically by assigning it to undefined value, or use delete to remove a property. Not an expert in javascript though, RTFM as I go :). Thanks!
uladz
July 16, 2024, 11:50pm
7
This assigns sku as ‘null’ string :).
1 Like
system
Closed
July 26, 2024, 11:51pm
8
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.