On Mon, Apr 24, 2017 at 10:53 PM, Raul-Sebastian Mihăilă
wrote:
> On Tue, Apr 25, 2017 at 12:15 AM, Tab Atkins Jr.
> wrote:
>>
>>
>> The obvious question is, why do you want to use `this`?
>>
>> ~TJ
>
>
>
> For cases such as a debounce function:
>
>
On Tue, Apr 25, 2017 at 12:15 AM, Tab Atkins Jr.
wrote:
>
> The obvious question is, why do you want to use `this`?
>
> ~TJ
>
For cases such as a debounce function:
```js
const debounce = (func, delay) => {
let timeout;
return function (...args) {
On Tue, Apr 25, 2017 at 6:19 AM, Jordan Harband wrote:
> Arrow functions are not constructible; just use one of those.
He said he wanted to use `this` within it (I'm assuming in a
non-closed-over way)...
-- T.J. Crowder
___
Arrow functions are not constructible; just use one of those.
On Mon, Apr 24, 2017 at 2:55 PM, J Decker wrote:
> function Entity() {
> if (this instanceof Entity) throw new Error("Please do not call with new");
> }
>
> oh the other side; you can bind this to a simple function
function Entity() {
if (this instanceof Entity) throw new Error("Please do not call with new");
}
oh the other side; you can bind this to a simple function call...
function f() {
}
var fWithThis = f.bind( {} /*Something to use as 'this' */ )
call with fWithThis()
and f's this will be the
You can use:
const foo = {
bar() {
// Not constructible
}
};
new foo.bar; //TypeError: foo.bar is not a constructor
On Mon, Apr 24, 2017 at 10:42 PM, Raul-Sebastian Mihăilă <
raul.miha...@gmail.com> wrote:
> I have a dilemma. I like how typically the built-in methods are not
>
On Mon, Apr 24, 2017 at 1:42 PM, Raul-Sebastian Mihăilă
wrote:
> I have a dilemma. I like how typically the built-in methods are not
> constructors (like Array.prototype.forEach). I have cases in which I'm
> creating a function in which I want to use `this` but I would
I have a dilemma. I like how typically the built-in methods are not
constructors (like Array.prototype.forEach). I have cases in which I'm
creating a function in which I want to use `this` but I would like the
function to not be constructible. There are ways of doing this:
- checking new.target -
8 matches
Mail list logo