首页 > 其他分享 >无涯教程-RegExp.prototype.global函数

无涯教程-RegExp.prototype.global函数

时间:2024-02-07 13:32:05浏览次数:32  
标签:prototype global Global 无涯 set RegExp property

global是RegExp对象的只读布尔属性。它指定特定的正则表达式是否执行全局匹配,即是否使用" g"属性创建。

RegExp.prototype.global - 语法

RegExpObject.global        

RegExp.prototype.global - 返回值

如果设置了" g"修饰符,则返回" TRUE",否则返回" FALSE"。

RegExp.prototype.global - 示例

var re=new RegExp( "string" ); 
if ( re.global ) {
   console.log("Test1 - Global property is set");  
} else { 
   console.log("Test1 - Global property is not set");  
} 
re=new RegExp( "string", "g" ); 

if ( re.global ) { 
   console.log("Test2 - Global property is set");  
} else { 
   console.log("Test2 - Global property is not set");  
}          

运行上面代码输出

Test1 - Global property is not set 
Test2 - Global property is set       

参考链接

https://www.learnfk.com/es6/es6-regexp-prototype-global.html

标签:prototype,global,Global,无涯,set,RegExp,property
From: https://blog.51cto.com/u_14033984/9637250

相关文章

  • 无涯教程-Math.atan2(y, x0)函数
    atan2方法介于-PI/2与PI/2弧度之间的数值来返回x的反正切值。Math.atan2-语法Math.atan2(x,y)x和y  - 代表一个数字Math.atan2-示例console.log("---Math.atan2()---")console.log("Math.atan2(0):"+Math.atan2(0,1))console.log("Math.atan2(M......
  • global.d.ts的作用是什么?
    global.d.ts文件在TypeScript项目中是一个全局声明文件,它的作用是为全局范围内的变量、函数或其他类型提供类型定义。这个文件中的声明可以让TypeScript编译器知道那些在运行时存在的、但未包含在任何模块中的全局变量和函数等。例如,在浏览器环境中,一些全局对象如window、do......
  • 无涯教程-Math.acos(x)函数
    此函数返回x的反余弦值。Math.acos(x)-语法Math.acos(x)x  - 代表数字Math.acos(x)-示例console.log("---Math.acos()---")console.log("Math.acos(0):"+Math.acos(0))console.log("Math.acos(Math.SQRT1_2):"+Math.acos(Math.SQRT1_2))......
  • 无涯教程-Math.asin(x)函数
    此函数返回x的反正弦。Math.asin(x)-语法Math.asin(x)x  - 代表数字Math.asin(x)-示例console.log("---Math.asin()---")console.log("Math.asin(0):"+Math.asin(0))console.log("Math.asin(Math.SQRT1_2):"+Math.asin(Math.SQRT1_2))......
  • 无涯教程-Math.max((x1, x2,...)函数
    此方法返回零或多个数字中的最大值。如果未提供任何参数,则输出为–Infinity。Math.max-语法Math.max(x1,x2,x3..)X1,x2,x3..  - 代表一系列数字Math.max-示例console.log("---Math.max()---")console.log("Math.max(3,0.5,0.66):"+Math.max(3,0.5,......
  • 无涯教程-Math.round(x)函数
    将数字四舍五入到最接近的整数。Math.round(x)-语法Math.round(x);x  - 代表数字Math.round(x)-示例console.log("---Math.round()---")console.log("Math.round(7.2):"+Math.round(7.2))console.log("Math.round(-7.7):"+Math.round(-7.......
  • 无涯教程-Math.floor(x)函数
    floor()方法对x进行下舍入。Math.floor(x)-语法Math.floor(x);x  - 代表数字Math.floor(x)-示例console.log("---Math.floor()---")console.log("Math.floor(2.8):"+Math.floor(2.8))console.log("Math.floor(-3.2):"+Math.floor......
  • 无涯教程-Math.ceil(x)函数
    ceil()方法对数进行上舍入。Math.ceil(x)-语法Math.ceil(x);x  - 代表数字Math.ceil(x)-示例console.log("---Math.ceil()---")console.log("Math.ceil(2.2):"+Math.ceil(2.2))console.log("Math.ceil(-3.8):"+Math.ceil(-3.8))......
  • 无涯教程-Math.sign(x)函数
    返回x的符号。Math.sign(x)-语法Math.sign(x);x  - 代表数字Math.sign(x)-返回值如果x为负,则返回-1。如果x为正则为1,如果x为0,则为0Math.sign(x)-示例console.log("---Math.sign()---")console.log("Math.sign(-10.5):"+Math.sign(-10.5))conso......
  • 无涯教程-Math.abs(x)函数
    此方法返回数字的绝对值。语法Math.abs(x);参数X-代表数字返回值返回数字的绝对值Exampleconsole.log("---Math.abs()---")console.log("Math.abs(-5.5):"+Math.abs(-5.5))console.log("Math.abs(5.5):"+Math.abs(5.5))输出---Math.abs......