Is there are proper way to $.extend a nested properties in jQuery?

前端 未结 1 544
臣服心动
臣服心动 2021-01-11 12:25

What I have and what I need. It\'s easy.

The default options (there are nested properties):

{
  sDom: \'frt<\"tfoot\"lp>\',
  bInfo: false,
  s         


        
相关标签:
1条回答
  • 2021-01-11 13:15

    You need a recursive copy by passing true as the first parameter:

    var defaults = {...}
    var actual = {...}
    
    //recursively merge to a blank object
    console.log($.extend(true,{}, defaults, actual))​
    
    0 讨论(0)
提交回复
热议问题