简体   繁体   中英

What is the “.” called in Javascript?

I know what it's used for, I know what it's called in language terms, but what is the official name of the period/dot used in Javascript/jQuery?

Thanks!

I've generally heard of it as a property accessor in JS as well as other languages. The ES5 spec refers to it as such. If you want to refer to the specific character, dot notation or operator is commonly used when discussing syntax.

The dot is the GET operator in Javascript, in ES2015 (the new standard of javascript) you can override what the get operator does for specific objects. Example:

var target = {};
var handler = {
  get: function (receiver, name) {
    return `Hello, ${name}!`;
  }
};

var p = new Proxy(target, handler);
p.world === "Hello, world!";

有人称之为dot notation ,有人称之为dot operator

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM