JavaScript property_exists function
A JavaScript equivalent of PHP’s property_exists
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
Example 1
This code
1 2 3 | |
Should return
1
| |
Example 2
This code
1 2 3 | |
Should return
1
| |
Other PHP functions in the classobj extension
- class_alias
- class_exists
- get_class
- get_class_methods
- get_class_vars
- get_declared_classes
- get_object_vars
- method_exists
- property_exists
Legacy comments
These were imported from our old site. Please use disqus below for new comments
Pete
on 2012-07-11 22:50:45
I think checking if cls is ‘undefined’ is reasonable, and if it is, then the function should also return false.
I think checking if cls is ‘undefined’ is reasonable, and if it is, then the function should also return false.
if(typeof cls === 'undefined'){
return false;
}