---
# System prepended metadata

title: '[jQuery] serialize() 排除空值'
tags: [jQuery]

---

# [jQuery] serialize() 排除空值
###### tags: `jQuery`

```javascript!

let str = $('#form').serialize();    //['test1=123', 'test2=41413', 'test3=dfgfdg', 'test4=sdsfgdf', 'test5=']

console.log(str.split("&").filter(function(value) {
    console.log(value + "," + value.endsWith("=") + "," + typeof(value));
  return !value.endsWith("=");
}));

//['test1=123', 'test2=41413', 'test3=dfgfdg', 'test4=sdsfgdf']
```