Skip to main content
Copy edited.
Source Link
Peter Mortensen
  • 31.5k
  • 22
  • 110
  • 134

OK, it looks like I had the right answer unless if you don't want inherited properties:

if (x.hasOwnProperty('key'))

Here are some other options to include inherited properties:

if (x.key) // quickQuick and dirty, but it does the same thing as below.

if (x.key !== undefined)

OK, looks like I had the right answer unless if you don't want inherited properties:

if (x.hasOwnProperty('key'))

Here are some other options to include inherited properties:

if (x.key) // quick and dirty but does the same thing as below.

if (x.key !== undefined)

OK, it looks like I had the right answer unless if you don't want inherited properties:

if (x.hasOwnProperty('key'))

Here are some other options to include inherited properties:

if (x.key) // Quick and dirty, but it does the same thing as below.

if (x.key !== undefined)
deleted 2 characters in body
Source Link
John Millikin
  • 201.8k
  • 41
  • 216
  • 228

OK, looks like I had the right answer unless if you don't want inherited properties:

if (x.hasOwnProperty('key'))

Here are some other options to include inherited properties:

if (x.key) // quick and dirty but does the same thing as below.

if (x.key !== 'undefined'undefined)

OK, looks like I had the right answer unless if you don't want inherited properties:

if (x.hasOwnProperty('key'))

Here are some other options to include inherited properties:

if (x.key) // quick and dirty but does the same thing as below.

if (x.key !== 'undefined')

OK, looks like I had the right answer unless if you don't want inherited properties:

if (x.hasOwnProperty('key'))

Here are some other options to include inherited properties:

if (x.key) // quick and dirty but does the same thing as below.

if (x.key !== undefined)
Source Link
sheats
  • 34.9k
  • 15
  • 49
  • 44

OK, looks like I had the right answer unless if you don't want inherited properties:

if (x.hasOwnProperty('key'))

Here are some other options to include inherited properties:

if (x.key) // quick and dirty but does the same thing as below.

if (x.key !== 'undefined')