I want to have a line of code similar to below:

var name = $('#input-name').attr("value");

However, the id 'input-name' is not guaranteed to exist. How do I check for its existence so that the assignment does not throw an error?

Edit
Report