Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a jQuery equivalent to Ruby’s Object#tap?

Does jQuery have an equivalent to Object#tap?

Let’s say I want to do something like this:

foo.append($("<nav>").tap(function (nav) {
  $.each(urls, function (url) {
    nav.append("<a>").attr(url).text(url)
  })
})
like image 262
Daniel Brockman Avatar asked Oct 10 '22 07:10

Daniel Brockman


1 Answers

It's called .each

nodes.each(inspect).map(mapper).each(inspect).etc()

like image 181
Raynos Avatar answered Oct 23 '22 01:10

Raynos