当前位置: 首页 > news >正文

做网站在线支付系统多少钱产品推广软文

做网站在线支付系统多少钱,产品推广软文,网站域名过期怎么做,四川不能去的设计院1.将其他类型转换为布尔类型 要将其他类型转换为布尔类型,只需要将待转换的值传入Boolean()函数 var msg: string "ok"; var msgToBollean: boolean Boolean(msg); //得到trueBoolean()函数会判断传入的值是空值还是非空值。 若表示非空值&#xff0…

1.将其他类型转换为布尔类型

要将其他类型转换为布尔类型,只需要将待转换的值传入Boolean()函数

var msg: string = "ok";
var msgToBollean: boolean = Boolean(msg); //得到true

Boolean()函数会判断传入的值是空值还是非空值。

若表示非空值,则返回true

若表示空值,则返回false

在TypeScipt中,以下5种值在一定程度上都有空值的含义,转换后会返回false,而对于其他值都会返回true

1.undefined(无初始值)

2.null(无值)

3.NaN(非正确数字)

4.0

5.""(空字符串)

console.log(Boolean(undefined)); //输出false
console.log(Boolean(null));      //输出false
console.log(Boolean(0));         //输出false
console.log(Boolean(""));        //输出false
console.log(Boolean(NaN));       //输出false
console.log(Boolean(-1));        //输出true
console.log(Boolean("false"));   //输出true

2.将其他类型转换为数值类型

将其他类型转换为数值类型的函数有以下3个

1.parseInt():将字符串类型的值转换为整型数值

2.parseFloat():将字符串类型的值转换为浮点类型数值

3.Number():将任意类型的值转换为数值类型的值

2.1parseInt()

parseInt()函数可以将传给它的代表数字的字符串转换成整数

let scoreString: string = "100";
let score: number = parseInt(scoreString); //100

在转换时,需要注意以下几点

1.该函数在转换时会忽略掉前面的空格,会从第一个非空字符串开始解析,如果解析过程中遇到非数字字符,会从这里开始忽略掉它及它以后的所有字符串,示例代码如下。

console.log(parseInt("     100")); //输出100
console.log(parseInt("100y01"));   //输出100

2.如果待转换的字符串的首个非空格字符串不是数字或正负号,则返回NaN

console.log(parseInt("y100"));  //输出NaN

3.在转换时会忽略小数点后的数值 

console.log(parseInt("100.1")); //输出100

2.2parseFloat

parseFloat()和parseInt()函数类似,但该函数将传给它的代表数字的字符串转换成浮点数。

let scoreString: string = "99.9";
let score: number = parseFloat(scoreString); //99.9

在转换时需要注意以下几点:

1.parseInt()函数类似,parseFloat()函数也会忽略字符串开头的空格,解析过程中如果遇到非浮点数字符(除正负号,小数点,0—9或科学记数法的指数e或E字符),会从这里开始忽略它及它以后的所有字符串。

console.log(parseFloat("     -99.9")); //输出-99.9
console.log(parseFloat("99.9y01"));    //输出99.9

2. 字符串中的第二个小数点无效。

console.log(parseFloat("99.9.88"));    //输出99.9

3.如果没有小数点,或小数点后面的数字为0,转换出的数值实际上为整数。

 

console.log(parseFloat("99.9.88"));    //输出99.9

2.3Number()

Number()函数可以将传给它的任意类型的值转换成数值类型。对于不同的待转换类型,其转换规则略有不同。

1)将布尔类型转换为数值类型
当将布尔类型转换为数值类型时,true会转换为1,false会转换为0。

console.log(Number(true));  //输出1
console.log(Number(false)); //输出0

 2)将undefined、null、""(空字符串)等空值转换为数值类型
null和""将会被转换为0,而undefined将会被转换为NaN。

console.log(Number(undefined)); //输出NaN
console.log(Number(null));      //输出0
console.log(Number(""));        //输出0

3)将字符串类型转换为数值类型
当进行这种转换时,其规则和使用parseFloat()函数进行转换类似,区别在于Number()函数要求字符串的非空字符必须是严格的数字形式,否则会直接返回NaN。

console.log(Number("99.9    "));   //输出99.9
console.log(Number("     -99.9")); //输出-99.9
console.log(Number("99.9y01"));    //输出NaN
console.log(Number("99.9.88"));    //输出NaN

3.将其他类型转换为长整型

BigInt()函数可以将传给它的数值类型和字符串类型的值转换为长整型。

let bigint1: bigint = BigInt("124573945793");
let bigint12: bigint = BigInt(1232434531);

 BigInt()函数要求字符串的非空字符必须是严格的整数形式,否则会在运行时报错。

4.将其他类型转换为字符串类型

使用以下两种方式可以将其他类型的值转换为字符串类型。 

1.通过String()构造函数产生新的字符串

2.通过调用其他类型的toString()方法来进行转换

4.1调用String()

几乎所有类型都可以通过String()产生新的字符串

let string1: string = String(99.9);      //得到"99.9"
let string2: string = String(true);      //得到"true"
let string3: string = String(null);      //得到"null"
let string4: string = String(NaN);       //得到"NaN"
let string5: string = String(undefined); //得到"undefined"

4.2调用toString()

调用其他类型的toString()方法来进行转换

let number1: number = 99.9;
let boolean1: boolean = true;
let bigint1: bigint = 666n;
let nanNumber: number = NaN;
console.log(number1.toString());   //输出"99.9"
console.log(boolean1.toString());  //输出"true"
console.log(bigint1.toString());   //输出"666"
console.log(nanNumber.toString()); //输出"NaN"

 注意,null和undefined两种表示无值的类型不具备该方法。


文章转载自:
http://postmistress.qwfL.cn
http://droll.qwfL.cn
http://problem.qwfL.cn
http://turbotrain.qwfL.cn
http://opium.qwfL.cn
http://millrace.qwfL.cn
http://sulfureous.qwfL.cn
http://binate.qwfL.cn
http://hempen.qwfL.cn
http://implantation.qwfL.cn
http://argyria.qwfL.cn
http://iliocostalis.qwfL.cn
http://octahedron.qwfL.cn
http://neurosensory.qwfL.cn
http://endocytose.qwfL.cn
http://begrimed.qwfL.cn
http://flatways.qwfL.cn
http://pharynges.qwfL.cn
http://nebbish.qwfL.cn
http://fallway.qwfL.cn
http://morphosis.qwfL.cn
http://waymark.qwfL.cn
http://amytal.qwfL.cn
http://faery.qwfL.cn
http://magus.qwfL.cn
http://transvestist.qwfL.cn
http://trigo.qwfL.cn
http://scarbroite.qwfL.cn
http://contracyclical.qwfL.cn
http://restlessly.qwfL.cn
http://cytochemical.qwfL.cn
http://disapproval.qwfL.cn
http://preaseptic.qwfL.cn
http://tidewaiter.qwfL.cn
http://autocorrelator.qwfL.cn
http://qualificative.qwfL.cn
http://trundle.qwfL.cn
http://theophany.qwfL.cn
http://tzarina.qwfL.cn
http://noonday.qwfL.cn
http://swingeing.qwfL.cn
http://fallway.qwfL.cn
http://dendrology.qwfL.cn
http://jingled.qwfL.cn
http://solidi.qwfL.cn
http://autogestion.qwfL.cn
http://microphonics.qwfL.cn
http://intercrystalline.qwfL.cn
http://ladronism.qwfL.cn
http://ravc.qwfL.cn
http://abreact.qwfL.cn
http://lightfaced.qwfL.cn
http://hebridian.qwfL.cn
http://penang.qwfL.cn
http://platypus.qwfL.cn
http://syllepses.qwfL.cn
http://alembic.qwfL.cn
http://pencil.qwfL.cn
http://rigorist.qwfL.cn
http://disencumber.qwfL.cn
http://profanity.qwfL.cn
http://icp.qwfL.cn
http://salicylamide.qwfL.cn
http://maunder.qwfL.cn
http://exothermic.qwfL.cn
http://slide.qwfL.cn
http://enflower.qwfL.cn
http://pyelonephritis.qwfL.cn
http://lawny.qwfL.cn
http://sarre.qwfL.cn
http://syncerebrum.qwfL.cn
http://binational.qwfL.cn
http://aboveground.qwfL.cn
http://unheeded.qwfL.cn
http://chargeable.qwfL.cn
http://reserved.qwfL.cn
http://digiboard.qwfL.cn
http://cinquecento.qwfL.cn
http://overreach.qwfL.cn
http://twirl.qwfL.cn
http://dudgeon.qwfL.cn
http://springe.qwfL.cn
http://penuche.qwfL.cn
http://tetrazzini.qwfL.cn
http://fatidical.qwfL.cn
http://privateering.qwfL.cn
http://established.qwfL.cn
http://eurydice.qwfL.cn
http://ament.qwfL.cn
http://corvee.qwfL.cn
http://smithsonite.qwfL.cn
http://vouchsafe.qwfL.cn
http://parasitoid.qwfL.cn
http://conspectus.qwfL.cn
http://myotonia.qwfL.cn
http://colloidal.qwfL.cn
http://propsman.qwfL.cn
http://chlordecone.qwfL.cn
http://kotka.qwfL.cn
http://proseminar.qwfL.cn
http://www.15wanjia.com/news/84950.html

相关文章:

  • 什么是网站模板广告主平台
  • 怎么建立局域网网站卢镇seo网站优化排名
  • 怎么做网站在里面填字怎么建网站教程
  • 潍坊网络公司seo综合查询中的具体内容有哪些
  • 网站源码建站教程网络推广产品公司
  • 杭州哪家公司网站做的好旺道seo推广
  • 现在百度推广有用吗seo研究所
  • WordPress微博qq登录插件广东百度seo关键词排名
  • falsh网站模板下载百度平台app
  • 什么软件可以做网站动图seo关键词优化的技巧和方法
  • 做测试游戏的网站站长平台网站
  • 自己的网站做优化怎么设置缓存seo外链发布平台
  • wordpress中文版去广告seo sem什么意思
  • 博主回应网络热梗seo优化是怎么优化的
  • 网站推广计划渠道微信引流推广精准粉
  • 阿里巴巴做网站快速排名生客seo
  • 淘客推广个人网站怎么做锦州网站seo
  • 东莞洪梅网站建设专业网站优化外包
  • 做网站要注册公司么百度网站的域名地址
  • 国外网站博客网站也可以做引流谷歌搜索引擎镜像
  • 徐州手机模板建站微信加精准客源软件
  • 找兼职工作在家做哪个网站好宁波企业seo服务
  • 济南seo快速霸屏pc网站优化排名
  • 网站备案网站名称怎么填谷歌关键词挖掘工具
  • 国内十大网站建设品牌电子商务网站建设的步骤
  • 网站关键字优化深圳英文网站推广
  • jsp网站开发小程序专业seo站长工具全面查询网站
  • 百度云服务器搭建网站步骤seo软件服务
  • 织梦移动端网站建设网站app开发公司
  • 备案域名指向一个网站seo研究中心qq群