Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Recursive function and json object

// Recursively print all properties of a JSON object
function printAllVals(obj) {
  for (let k in obj) {
    if (typeof obj[k] === "object") {
      printAllVals(obj[k])
    } else {
      // base case, stop recurring
      console.log(obj[k]);
    }
  }
}
Source by blog.boot.dev #
 
PREVIOUS NEXT
Tagged: #Recursive #function #json #object
ADD COMMENT
Topic
Name
4+3 =