-2

I have an Object of arrays.And its output looks like this. Object of array output

enter image description here

And code is like this

layer.fields.each(function(field) {
tr.append($('<th ></th>').text(field.name));
if(self.availableForTable.indexOf(field.name.toUpperCase()) != -1)
self.tblHeader.push(field.name);
});
tbody.append(tr);`

Now the issue is that I got some entries empty from database. like this like after 1 line 2nd line is empty.

enter image description here

Now how to remove this empty space. Is there any way in javascript for "Object of Array"?I searched on StackOverflow but didn't get any useful thing so far

9
  • Post your ouput data as well.. Commented May 9, 2017 at 5:21
  • both images are output @Ved Commented May 9, 2017 at 5:21
  • layer = layer.filter(function(entry) { return /\S/.test(entry); }); will remove white spaces from array Commented May 9, 2017 at 5:22
  • Image you shared is Array of arrays. Commented May 9, 2017 at 5:23
  • what do you mean by 'Object of array output'? Commented May 9, 2017 at 5:23

1 Answer 1

0

To remove white spaces from array do like below:-

layer = layer.filter(function(entry) { return /\S/.test(entry); }); 
Sign up to request clarification or add additional context in comments.

6 Comments

@F128115 glad to help you :):)
Can I ask a little more ? In 2nd case I have a Object containing objects. Now what I have to do to remove empty objects ?
@F128115 please check this:-stackoverflow.com/a/42736367/4248328
on both ways I getting undefined
@F128115 ask a new question with some input data and what you tried ? you will get answer for-sure
|

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.