javascript - What is the meaning of forward slash in a JavaScript expression?
问题描述
Stumbling upon a piece of JavaScript in a library I found this:
let useBlobFallback = /constructor/i.test(window.HTMLElement) || !!window.safari || !!window.WebKitPoint
but I can't find the meaning of the /constructor/i
. Even searching online produces meaningless results because of the 'constructor' word and/or because the slash is also used in regular expressions. Which I believe it's not the case in this code snippet..
解决方案
This is a RegExp literal. It's equivalent to new RegExp('constructor', 'i').test(window.HTMLElement)
.
推荐阅读
- amazon-web-services - 从 openvpn 网络中的远程计算机使用私有主机名访问 AWS 中的 ec2 实例
- azure - azure pipelines ansible 任务失败并出现以下错误
- django - 在 Django 中,我试图显示“for loop”的输出
- kotlin - Kotlin 1.4 中的 sumOf() 和 sumBy() 有什么区别?
- javascript - 提交表单时不保存该值
- vaadin - Vaadin 对话框在方法执行之后而不是之前打开
- javascript - 保存动态用户输入 - Angular
- linux - 当内存压力很高时,linux是否使用异步写入进行交换?
- c# - 暴露 JS 方法时 IE 崩溃
- facebook - 如何使用 Facebook 图形 API 仅检索具有特定关键字的 Facebook 帖子的特定评论?请指教