What is jQuery.isPlainObject() in jQuery?

What is jQuery.isPlainObject() in jQuery?

Comments

  • Description: Check to see if an object is a plain object (created using "{}" or "new Object").

    Example:
    $(function(){
      $('#btn2').one('click', function(){
        var obj1 = 'A string', obj2 = {}, obj3 = new Object;
        $('#div2').append('Is obj1 plain JavaScript object? ' +  $.isPlainObject(obj1) + '<br />');
        $('#div2').append('Is obj2 plain JavaScript object? ' +  $.isPlainObject(obj2) + '<br />');
        $('#div2').append('Is obj3 plain JavaScript object? ' +  $.isPlainObject(obj3) + '<br />');
      });
    });
    
    Output:
    Is obj1 plain JavaScript object? "false"
    Is obj2 plain JavaScript object? "true"
    Is obj3 plain JavaScript object? "true" >jQuery.isPlainObject() return boolean(true or false).
Sign In or Register to comment.