javascript - Remove specified element from associated array -


hi looking ways delete elements associate array. need remove values null , '' while in loop. cant because know need identify , build array store, use elements in new array seek , remove them.

var storedata3 = [   { 'key' : 'value1' },   { 'key' : 'value2' },   { 'key' : 'value3' },   { 'key' : null },   { 'key' : '' },   { 'key' : 'value10'} ]; 

try this:-

using array.filter data after omitting unwanted data.

 var result= storedata3   .filter(function(val){        return (val.key != '' && val.key != null)}); 

.filter()

fiddle


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -