What do the parentheses of object attributes mean in es6

what do the parentheses of object attributes mean in es6?

in the change event of the input box of the react form

handleChange = (e) => {
    console.log(e);
    this.setState({
      value: e.target.value
    });
}

the event object here is a proxy object. Print it to the console and output it as follows

[[Handler]] : Object
  set :  (target, prop, value)
  __proto__ : Object
[[Target]] : SyntheticEvent
  bubbles : (...)
  cancelable : (...)
  currentTarget : (...)
  defaultPrevented : (...)
  dispatchConfig : null
  eventPhase : (...)
  isDefaultPrevented : null
  isPropagationStopped : null
  isTrusted : (...)
  nativeEvent : (...)
  target : (...)
  timeStamp : (...)
  type : (...)
  _dispatchInstances : null
  _dispatchListeners : null
  _targetInst : null
  preventDefault : (...)
  stopPropagation : (...)
  get bubbles :  ()
  set bubbles :  (val)
  get cancelable :  ()
  set cancelable :  (val)
  get currentTarget :  ()
  set currentTarget :  (val)
  get defaultPrevented :  ()
  set defaultPrevented :  (val)
  get eventPhase :  ()
  set eventPhase :  (val)
  get isTrusted :  ()
  set isTrusted :  (val)
  get nativeEvent :  ()
  set nativeEvent :  (val)
  get target :  ()
  set target :  (val)
  get timeStamp :  ()
  set timeStamp :  (val)
  get type :  ()
  set type :  (val)
  get preventDefault :  ()
  set preventDefault :  (val)
  get stopPropagation :  ()
  set stopPropagation :  (val)
  __proto__ : Object
[[IsRevoked]] : false

if it is a function object, it will have such a structure

arguments : (...)
caller : (...)
length : 0
name : ""
prototype : {constructor: }
__proto__ :  ()
[[FunctionLocation]] : emptyFunction.js:13
[[Scopes]] : Scopes[2]

what"s the point of naming the [[]] (both parentheses) attribute in this object?


parentheses indicate that this is a property / method used internally in the JavaScript engine, which can help debug (click [[FunctionLocation]] to jump to the definition, click [[Scopes]] to view closures), but normal JavaScript code cannot get these attributes.

The

engine decides which internal attributes to display according to the mood, and the format of the display is not specified, but in the console, it is generally customary to use both parentheses to keep the format consistent with the specification.

ECMA Standard: Object Internal Methods and Internal Slots

Menu