2.1.19 [ECMA-ES2017] Section 14.3.7 Runtime Semantics: DefineMethod

V0067: Methods defined in object literals are created with their own property named prototype

The specification states:

 14.3.7 Runtime Semantics: DefineMethod
  
     With parameters object and optional parameter functionPrototype.
  
     MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody }
  
         1.  Let propKey be the result of evaluating PropertyName.
         2.  ReturnIfAbrupt(propKey).
         3.  If the function code for this MethodDefinition is strict mode code, let 
             strict be true. Otherwise let strict be false.
         4.  Let scope be the running execution context's LexicalEnvironment.
         5.  If functionPrototype is present as a parameter, then
             a. Let kind be Normal.
             b. Let prototype be functionPrototype.
         6.  Else,
             a.  Let kind be Method.
             b.  Let prototype be the intrinsic object %FunctionPrototype%.
         7.  Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, 
             scope, strict, prototype).
         8.  Perform MakeMethod(closure, object).
         9.  Return the Record{[[Key]]: propKey, [[Closure]]: closure}.

EdgeHTML Mode

Methods defined in object literals are created with their own property named prototype, contrary to DefineMethod. In the following example, false should be logged, but instead true is.

    var obj = { method() { } };

    console.log(Object.hasOwnProperty(obj.method, 'property'));

V0066: Object literal methods can successfully be used as the target of new expressions

The specification states:

 14.3.7 Runtime Semantics: DefineMethod
  
     With parameters object and optional parameter functionPrototype.
  
     MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody }
  
         1.  Let propKey be the result of evaluating PropertyName.
         2.  ReturnIfAbrupt(propKey).
         3.  If the function code for this MethodDefinition is strict mode code, let 
             strict be true. Otherwise let strict be false.
         4.  Let scope be the running execution context's LexicalEnvironment.
         5.  If functionPrototype is present as a parameter, then
             a. Let kind be Normal.
             b. Let prototype be functionPrototype.
         6. Else,
             a.  Let kind be Method.
             b.  Let prototype be functionPrototype [prior to 2018, "the intrinsic object 
             %FunctionPrototype%"].
         7.  Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, 
             scope, strict, prototype).
         8.  Perform MakeMethod(closure, object).
         9.  Return the Record{[[Key]]: propKey, [[Closure]]: closure}.

EdgeHTML Mode

Object literal methods are created with a [[Construct]] slot, contrary to DefineMethod. Therefore the methods can successfully be used as the target of new expressions. In the following example, the new expression should throw a TypeError, but doesn't.

    var obj = { meth() { } };

    new obj.meth();