When to use setter methods?

When to use setter methods?

Hi,

I am a little confused about when to use setter methods. For example, I have this code 

  1. $("input[placeholder]").val($("input[placeholder]").attr("placeholder"));
should this be used like this

  1. $("input[placeholder]").val(function(i, value) {
  2.             return $("input[placeholder]").attr("placeholder");
  3.             });
I think a better question is when to use the .each loop? Since, the first line of code I have works fine.

Thanks for your help.