Test prop 19 years old

<script src="https:///ajax/libs/jquery//"></script> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>prop demo</title> <style> p { margin: 20px 0 0; } b { color: blue; } </style> </head> <body> <input id="check1" type="checkbox" checked="checked"> <label for="check1">Check me</label> <p></p> <script> $("input").change(function() { var $input = $(this); $("p").html( ".attr( \"checked\" ): <b>" + $("checked") + "</b><br>" + ".prop( \"checked\" ): <b>" + $("checked") + "</b><br>" + ".is( \":checked\" ): <b>" + $(":checked")) + "</b>"; }).change(); </script> </body> </html>

Something else to consider when it comes to object properties is whether you really want to check for undefined at all. A given property name can be absent on an object (producing the value undefined when read), present on the object itself with the value undefined , present on the object’s prototype with the value undefined , or present on either of those with a non- undefined value. 'key' in obj will tell you whether a key is anywhere on an object’s prototype chain, and (obj, 'key') will tell you whether it’s directly on the object. I won’t go into detail in this answer about prototypes and using objects as string-keyed maps, though, because it’s mostly intended to counter all the bad advice in other answers irrespective of the possible interpretations of the original question. Read up on object prototypes on MDN for more!

Test prop 19 years old

test prop 19 years old


test prop 19 years oldtest prop 19 years oldtest prop 19 years oldtest prop 19 years oldtest prop 19 years old