Bug Tracker

Modify

Ticket #7955 (closed bug: invalid)

Opened 3 years ago

Last modified 3 years ago

isPlainObject slight error

Reported by: ben@… Owned by:
Priority: undecided Milestone: 1.next
Component: misc Version: 1.4.4
Keywords: Cc:
Blocking: Blocked by:

Description

The return value for this is: for(key in obj) { }

return key === undefined
hasOwn.call( obj, key );

Unless I'm mistaken, shouldn't key === undefined actually be key !== undefined? If key is undefined that would mean the for..in loop found no properties.

Change History

comment:1 Changed 3 years ago by jitter

  • Status changed from new to closed
  • Resolution set to invalid
  • Component changed from unfiled to misc

Thanks for taking the time to contribute to the jQuery project by writing a bug report.

There is no bug here. The conditional is correct (an object with no properties is still an object).

If you would switch === to !== then isPlainObject would yield wrong results. E.g.

jQuery.isPlainObject( {} ); //would yield false instead of true
jQuery.isPlainObject( document); //would yield true instead of false

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.