Avatar of gautam_reddyc
gautam_reddyc
 asked on

How to avoid undefined index in Javascript

Hello, I am trying to load an array with client side actions, but in the process there are a few unnecessary fields loading in. They have a blank id and a value of undefined. How can i avoid these undefined values to load into my array.

When I tried to get them by using a conditional if loop where the value == 'undefined', they still load into the array. Is there a remedy for this. There are a lot of these, so using this array has been a problem.
JavaScriptJScript

Avatar of undefined
Last Comment
leakim971

8/22/2022 - Mon
andrux

Can you provide your code?
ASKER CERTIFIED SOLUTION
leakim971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
alien109

if the value is null then test for: value == null

if it is undefined then test for: value == undefined

you can even do a strict equality (===) but I'm not sure that's necessary. fyi - don't enclose null or undefined in quotes! :)
leakim971

Thanks a lot for the points! Have a nice week-end!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck