인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

rudals89201749's profile image
rudals89201749

asked

JavaScript Intermediate to Advanced: Engine Core

1. Recursive functions, property linkage prevention, recursive function form, [cleanup time]

[정리시간] 해보았습니다!

Written on

·

166

0

'use strict'

var member = {
  jan: {
    item:{
      title: "JS북",
      amount: 100
    },
    point: [102030]
  },

  feb: {
    item:{
      title: "HTML",
      amount: 200
    },
    point: [405060]
  }
}




function show(param){
  for(var type in param){
    if(Object.prototype.toString.call(param[type] ) === "[object Object]"){
      show(param[type]);
    }else if(Array.isArray(param[type])){
      console.log(param[type])
    }else{
      console.log(type + ":" + param[type])
    }
  }
}

show(member)
// title:JS북 amount:100 (3) [10, 20, 30] title:HTML amount:200 (3) [40, 50, 60]


javascript

Answer

This question is waiting for answers
Be the first to answer!
rudals89201749's profile image
rudals89201749

asked

Ask a question