How to use 'destructure nested object' in JavaScript

Every line of 'destructure nested object' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
12function destructure(key, value) {
13 if (Array.isArray(value)) {
14 for (var i = 0; i < value.length; i++) {
15 destructure(key + "[" + i + "]", value[i])
16 }
17 }
18 else if (Object.prototype.toString.call(value) === "[object Object]") {
19 for (var i in value) {
20 destructure(key + "[" + i + "]", value[i])
21 }
22 }
23 else args.push(encodeURIComponent(key) + (value != null && value !== "" ? "=" + encodeURIComponent(value) : ""))
24}

Related snippets