Most voted "this" questions
11 questions
Sort by count of
-
20
votes1
answer3182
viewsWhat is and how does context (this) work in Javascript?
Essential part of Javascript, every function has context (this). How it works, how to manipulate it and what changes in strictly speaking ('use strict')?…
-
10
votes2
answers85
views"this" within object properties
In the code below, the first console.log(this) returns the object example (so far so good). The second console.log(this) returns the object window. Why does this happen? Why, even inside an object,…
-
10
votes2
answers573
viewsGlobal variable returns Undefined when using this in Node.js
I’m studying about the special variable this and I came across the following situation: When executing the function below in Node.js (version 12.18.3) the result is undefined and only returns 2 if I…
-
5
votes3
answers177
viewsWhy does the this(6) command inside a constructor initialize the class array?
In the code: public class Lista{ int [] a; int n; public Lista(){ this(6); } public Lista(int i){ this.a = new int [i]; this.n = 0; } public static void main(String [] args){ Lista l = new Lista();…
-
5
votes1
answer36
viewsWhy can’t I use add operator in function with this?
Why when I run the following code: function Pessoa(){ this.idade = 0; console.log(this.idade); setTimeout(function() { this.idade++; console.log(this.idade); }, 2000); } new Pessoa(); My way out is…
-
1
votes1
answer37
viewsthis is assuming the value of Window
I don’t know what’s wrong with this code. Inside the function builder EvilCircle, the this works well, but in EvilCircle.prototype.draw doesn’t work. It looks like it turns into Window. function…
-
1
votes1
answer37
viewsThe property this is returning Undefined in typescript
hello! I have this code typescript: import { InternalService } from './../services/InternalServices'; import { Request, Response } from "express"; class InternalController { internalService = new…
-
0
votes0
answers31
viewsAndroid Studio How to reference Activity within a Static method
I needed to create a static method in the main Activity, because Firebase is not accepting Framents within the CreateUserWithEmailAndPassword. I would like to know how I refer to the main Activity…
-
0
votes0
answers14
viewsHow to use call, apply and bind?
Can someone demonstrate/explain how to use call, apply and bind methods in javascript? Simple examples and objectives are very welcome! Further explanations also :D Extra points for those who can…
-
0
votes0
answers13
viewsDoubt about this and Arrow Function
Good afternoon, I have a question about this and Arrow Function. For example: const user = { age: 32, halfAge(){ return this.age/2; }, doubleAge: () => 2 * this.age; }…
-
0
votes2
answers51
viewsC++ - pointer this
The Rotatex(float) and Scale(float, float, float) functions of the mat4 class return the this pointer. The purpose was to create a temporary instance of mat4 to store the pre-multiplication between…