# JS Quiz: Hard: Prototype method and detached call

**URL:** <https://forum.kirupa.com/t/js-quiz-hard-prototype-method-and-detached-call/682789>\
**Category:** web dev\
**Created:** [July 28, 2026, 7:00am UTC](https://forum.kirupa.com/t/js-quiz-hard-prototype-method-and-detached-call/682789 "2026-07-28T07:00:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![VaultBoy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/vaultboy/32/31832_2.png) [@VaultBoy](https://forum.kirupa.com/u/VaultBoy)\
**Post date:** [July 28, 2026, 7:00am UTC](https://forum.kirupa.com/t/js-quiz-hard-prototype-method-and-detached-call/682789/1 "2026-07-28T07:00:16Z")

</div>

What is logged in strict mode?

```js
"use strict";
class Counter {
  constructor() { this.n = 1; }
  inc() { this.n += 1; return this.n; }
}
const c = new Counter();
const fn = c.inc;
try {
  console.log(fn());
} catch (e) {
  console.log(e.name);
}

```

_Poll ([view on site](https://forum.kirupa.com/t/js-quiz-hard-prototype-method-and-detached-call/682789/1))_

---

<div class="post-metadata">

**Author:** ![Quelly](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/quelly/32/31386_2.png) [@Quelly](https://forum.kirupa.com/u/Quelly)\
**Post date:** [July 29, 2026, 7:20am UTC](https://forum.kirupa.com/t/js-quiz-hard-prototype-method-and-detached-call/682789/2 "2026-07-29T07:20:24Z")

</div>

TypeError, because class methods are strict mode by default even without the pragma, and `this` never gets auto-boxed to globalThis like it would in a plain function.

Detach a regular old function from an object and call it bare, and non-strict mode quietly hands you the global object as `this`, so `this. n += 1` just creates a garbage global property and moves on. Classes don’t get that safety net at all, strict or not, so the failure mode here isn’t really about the “use strict” string at the top.

---

<div class="post-metadata">

**Author:** ![VaultBoy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/vaultboy/32/31832_2.png) [@VaultBoy](https://forum.kirupa.com/u/VaultBoy)\
**Post date:** [July 29, 2026, 8:00am UTC](https://forum.kirupa.com/t/js-quiz-hard-prototype-method-and-detached-call/682789/3 "2026-07-29T08:00:06Z")

</div>

**JS Quiz answer:** Option 3 (C).

**Correct choice:** TypeError

**Why:**  
Detached method call has undefined this in strict mode, so accessing this.n throws.

**Go deeper:**

> **[Using Prototype to Add New Properties | kirupa.com](https://www.kirupa.com/html5/using_js_prototype_to_add_new_properties.htm)**
>
> Get a quick overview of how to use prototypes in JavaScript to extend the properties an object exposes.
