L
L
lMoJlo4HuKl2018-01-30 18:32:48
JavaScript
lMoJlo4HuKl, 2018-01-30 18:32:48

Why is this the value of the property?

Why in the code below, "this" which inside "each" displays the value of the property of the object(e) ?

$('.someButton').on('click',function () {
   console.dir(this);

    $.each(this,function (e) {

        console.log(e,this);
    })
})

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Kositsyn, 2018-01-30
@lMoJlo4HuKl

Perhaps you're asking why the property values ​​for each .someButton object are displayed
?
If I understand the question correctly. Then in this case you have this which is passed as an argument to the first parameter of each - this is one of the .somrButton instances. and then you do this for this instance (this is an object with many sv you): for each property, print its values ​​to me in console. Why is that? Because the this in each for an object is the values ​​of each.

V
Vladimir, 2018-01-30
@ambrazhey

https://learn.javascript.ru/object-methods

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question