Skip to main content

Questions tagged [this]

In many object-oriented languages, "this" is a reference to the current instance of the class or object. Use with a language tag, like [javascript], [java], [c#], etc.

this
0 votes
1 answer
40 views

In Alpine.JS, this.property inside method is undefined

I have a request for help with Alpine.JS I have a packetaApiKey property defined. When I access it this.packetaApiKey in the pickPoint method, it works as expected. But in the showSelectedPickupPoint ...
Marek Vinárčik's user avatar
0 votes
1 answer
42 views

multiple `thisArg`s with module function?

There are lots of questions on here about this, but "multiple this args" is getting me answers about how to declare multiple properties under this, which isn't what I'm after. If this is ...
philolegein's user avatar
  • 1,417
-2 votes
0 answers
13 views

Why constructor cannot access static variable inside the constructor block?

Why static variable can't be accessed using this keyword inside a constructor I created a static variable and a no argument constructor inside a class when I try access the static variable with the ...
Yogi's user avatar
  • 1
8 votes
1 answer
315 views

MSVC rejects program with member function call while gcc and clang accept

I wrote the following program in C++23 that compiles with gcc and clang but is rejected by msvc. I want to know is this well-formed or ill-formed etc as per the standard. Live demo struct C { void ...
Alex's user avatar
  • 373
0 votes
1 answer
50 views

What forms a scope in javascript? [duplicate]

While reading about 'this' keyword and arrow function, I read: that arrow functions binds to whatever execution context the surrounding scope has. I have attached a simple code example below. When I ...
aarshin gupta's user avatar
0 votes
1 answer
67 views

Can I directly assign a new object reference variable to the original current object, inside the object class?

Lets say I am trying to reverse a SinglyLinkedList object list. I would do so like this: public void reverseList() { SinglyLinkedList<E> reverse = new SinglyLinkedList<>(); Node<...
tarrzaann's user avatar
0 votes
0 answers
27 views

what is the 'this' keyword in the .on method's callback function of leaflet library?

Im curious because the this keyword inside of JavaScript's event handler function is the element in which the .eventListener() is attached to. And the .on() method of leaflet library is similar to ....
huz3y's user avatar
  • 21
0 votes
0 answers
54 views

Why does the keyword "this" work like this in these examples [duplicate]

I was looking for examples of how "this" works and found this example: function foo() { return { x: 20, bar: () => { console.log(this.x); }, baz: ...
Stoble's user avatar
  • 11
0 votes
3 answers
51 views

Unable to Close Child Window Inside setTimeout Callback in JavaScript

I'm encountering an issue with closing a child window inside a setTimeout callback in JavaScript. Despite successfully opening the child window using window.open, I am unable to access the newChild ...
laktherock's user avatar
0 votes
1 answer
53 views

pass javascript function as paremeter with THIS in the implementation - bind and apply don't work [duplicate]

I'm trying to create a library that allows the user to pass a custom function. This custom function has to be able to use the properties of the parent object, which holds references determined at ...
The Fox's user avatar
  • 533
0 votes
0 answers
21 views

Why does the 'this' keyword change what it refers to? [duplicate]

Let's take the following short program as an example: var Space = Space || (function(){ return { recursive: function(){ console.log(this); setTimeout(this.recursive,...
MMDR's user avatar
  • 1
3 votes
2 answers
57 views

Difference between func.apply(this, args) and func(...args) in closures

I came across the following thing while trying to understand some concepts of working with closures. When I was reading about memoization/throttling, people were using func.apply(this, args) in ...
deadboyFreak's user avatar
0 votes
2 answers
57 views

Can I have identiers looked up first as members of this, and then as globals?

I write JS (well, EcmaScript), but only relatively rarely. When writing on a member function for an object, I naturally often use other member variables and functions multiple times; but I tend to ...
einpoklum's user avatar
  • 127k
1 vote
1 answer
26 views

Possible to annotate inline "this" with comment types with Flow?

Getting this error: Missing an annotation on implicit this parameter of function. Would be nice to be able to annotate this with comment types. Possible? https://flow.org/en/docs/types/comments/
Olle Härstedt's user avatar
1 vote
1 answer
35 views

How to use with on a protected member extension in Kotlin?

I stumbled upon this when trying to create a custom androidx.compose.ui.graphics.painter.Painter for my jetpack compose application. I'd like to create a decorator like: class MyPainter(private val ...
Jezor's user avatar
  • 3,386

15 30 50 per page
1
2 3 4 5
423