> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/js/val/prim/str/ext/ispunctuator.md).

# str.isPunctuator

[JS](/web/js.md) ⟩ [primitives](/web/js/val/prim.md) ⟩ [String](/web/js/val/prim/str.md) ⟩ [custom members](/web/js/val/prim/str/ext.md) ⟩ .isPunctuator

{% tabs %}
{% tab title="💾 程式" %}

* replit：[punctuators](https://replit.com/@pegasusroe/punctuators#index.js)

```javascript
// 📁 String_ext.js

// punctuators
const punctuators = [
  '?.',  '{',   '}',    '(',  ')',  '[',
  ']',   '.',   '...',  ';',  '',   '',
  '<',   '>',   '<=',   '>=', '==', '!=',
  '===', '!==', '+',    '-',  '*',  '/',
  '%',   '**',  '++',   '--', '<<', '>>',
  '>>>', '&',   '|',    '^',  '!',  '~',
  '&&',  '||',  '??',   '?',  ':',  '=',
  '+=',  '-=',  '*=',   '/=', '%=', '**=',
  '<<=', '>>=', '>>>=', '&=', '|=', '^=',
  '&&=', '||=', '??=',  '=>'
];

// getters for String
Object.defineProperties(String.prototype, {

    // 🔸 str.isPunctuator
    isPunctuator: {
        
        get() { return punctuators.includes(this.valueOf()) }
        //                                       ^^^^^^^^^
        // 🧨 雷區
        // -----------------------------------------------
        // get() { return keywords.includes(this) }
        //                                  ^^^^
        // ❗ `this` will be "wrapped" in a `String` object,
        //    hence `false` is "always" returned.
        
    },

});

// export
module.exports = {punctuators};
```

{% endtab %}

{% tab title="💈範例" %}

* replit：[punctuators](https://replit.com/@pegasusroe/punctuators#index.js)

```javascript
// import String extensions
const _StringExt = require('./String_ext.js');

'->'.isPunctuator,    // false
'=>'.isPunctuator,    // true
```

{% endtab %}

{% tab title="⬇️ 應用" %}

* [punctuator](/web/js/grammar/token/punctuator.md)
  {% endtab %}
  {% endtabs %}
