javascript - 如何挂钩新 String 实例的每次创建?
问题描述
是否可以挂钩每个新的创建String
?每次运行这样的代码:
const new_string = 'Hello World!';
我想收到通知;例如;
console.log('A new String was created:', whatever_new_string_was_created);
解决方案
字符串是没有关联事件的原语,构造函数无法更改其方法:https ://tc39.es/ecma262/#sec-string-objects
推荐阅读
- reactjs - Material-ui 弹出状态弹出框不工作
- javascript - 如何检测对列表元素的点击?
- python - 通过 Django Admin 中的多个表查找特定用户的实体
- postgresql - 数字中的时间戳差异
- python-3.x - Colab OSError:[Errno 36] 读取 docx2text 文件时文件名太长
- exception - 尝试?在 Swift 4 中返回双可选
- javascript - 如何在 REACT 中将 json 对象请求字符串值更新为 NUMBER
- performance - KieBuilder 加载 kieFileSystem 和构建的时间太多
- python - Python 使用 pyinstaller 创建 exe 文件
- c++ - 从 R&H 频谱分析仪读取增量值