Why if the component is removed by this means, it will be removed in the form of a body and without it in the form of a text?
-
There's a code:
const video = { title: 'a', play() { console.log(this); } }; video.play();
It turns out in the console:
If instead of this, write just video.play,
In fact, I challenge the same constant, but as a result, the data are different, why is that the special features of JS or do I not understand?
-
const video = {}
This is an object.
play() {}
This function is created inside the facility and is applied to the facility (method).
video.play();
Implement the play method for the video facility.
play(){
console.log(this)
}
In this case, the "this" is an application to an object within which this code line is executed to the object "video." Foreword:
показать в консоли(этот объект)
https://habr.com/ru/company/ruvds/blog/419371/