Skip to content

Tag: this

How to access an array from the scope of a function

I’m trying to add an element into an array with the push() method but apparently, I can’t access that array from the scope of my function. Here’s a summary of my architecture : I know for sure that the problem come from the array. When executing the code, I have an error telling me that push…

JS call static method from class

I have a class with a static method: Is there an equivalent to this for static methods (i.e. refer to the current class without an instance)? So I don’t have to write the class name: “User”. Answer From MDN documentation Static method calls are made directly on the class and are not callable…

Javascript call() & apply() vs bind()?

I already know that apply and call are similar functions which set this (context of a function). The difference is with the way we send the arguments (manual vs array) Question: But when should I use the bind() method ? jsbin Answer I created this comparison between function objects, function calls, call/appl…