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

深圳家装互联网网站百度推广关键词技巧定价

深圳家装互联网网站,百度推广关键词技巧定价,兰州企业网络优化方案,哪些网站可以做网店文章目录 前言 一:强制类型转换 1:强制类型转换为String (一):方式一:调用被转换类型的toString()方法 (二):方式二:调用String函数 2:强制类型转换为Number (一):方式一&…

文章目录

前言

一:强制类型转换

1:强制类型转换为String

(一):方式一:调用被转换类型的toString()方法

(二):方式二:调用String函数

2:强制类型转换为Number

(一):方式一:调用Number函数

(二):方式二:这种方式专门对付字符串


前言

        JS中数据类型有6种,基本数据类型有5种。String,Number,Boolean,Null,Undifined。Object属于引用数据类型。

一:强制类型转换

        首先,我们强制类型转换的角色是,String,Number,Boolean。不会有人转换为Null和Undefined的,因为确实没啥意义。

1:强制类型转换为String

(一):方式一:调用被转换类型的toString()方法

var a = 123;
a.toString();
console.log(typeOf a);//number

        toString()不会影响值本身,需要使用他的返回值

var a = 123;
var b = a.toString();
console.log(typeOf b);//string

        这么干,也行!

var a = 123;
a = a.toString();
console.log(typeOf a);//string
//
var a = 123;
a = null;
a = a.toString() //这一行会报错
console.log(typeOf a);//object

        报错如下:

Uncaught TypeError: Cannot read properties of null (reading 'toString')at <anonymous>:1:21
(匿名) @ VM102:1

        需要注意的是,null和undefined没有toString()方法。

        也就是方式一是有局限性的,只适用于Boolean、String、Number

(二):方式二:调用String函数

        调用什么什么函数,就直接写xxxx()就完事了。被转换数据作为参数。

var a = 123;
a = String(a);
console.log(typeOf a); // String
var a = null;
a = String(a);
console.log(typeOf a); // string
console.log(a); //null
var a = undefined;
a = String(a);
console.log(typeOf a); // string
console.log(a); //undefined

        String()函数转字符串时,对于Number、Boolean实际上调用的就是toString()方法。但是对null和undefined直接转换为他俩的字符串。

2:强制类型转换为Number

        值得注意的是,没有toNumber()方法

var a = "123";
console.log(typeOf a); //string
console.log(a); //a

(一):方式一:调用Number函数

        字符串转数值,如果是纯数字字符串,可以直接转换。

var a = "123";
a = Number(a);
console.log(typeOf a); // number

        如果字符串中有非数字内容,就直接转换为NaN

        如果字符串字符串中是一个空串或者是全是空格,转换为0

a = true;
a = Number(a);
console.log(a);//1

        布尔转数字是固定的,false转0,ture转1;

a = null;
a = Number(a);
console.log(a);//0a = undefined;
a = Number(a);
console.log(a);//0

        null和undefined转数字都是0

var a = 123px;
console.log(a);//123px

(二):方式二:这种方式专门对付字符串

        parseInt()把一个字符换转换为一个整数,parseFloat()把一个字符换转换为一个浮点数

var a = "123px";
a = parseInt(a);
console.log(typeOf a);//number
console.log(a);//123

        parseInt()方法从左到右去读数字,遇到第一个不是数字的内容停止读取,并且返回前面的数字。123.456px到小数点就完事了。

        

var a = "123.456px";
a = parseFloat(a);
console.log(a);//123.456

        这个特点就是,遇到小数点.不停止,继续往下读。 值得注意的是,如果对非String类型使用parseInt()和parseFloat()会先将他转换为String在进行操作!


文章转载自:
http://syncline.zfqr.cn
http://speedlight.zfqr.cn
http://intercommunity.zfqr.cn
http://auximone.zfqr.cn
http://unbearded.zfqr.cn
http://bratislava.zfqr.cn
http://victrix.zfqr.cn
http://inwoven.zfqr.cn
http://expressively.zfqr.cn
http://sovietist.zfqr.cn
http://isd.zfqr.cn
http://elegancy.zfqr.cn
http://sulkily.zfqr.cn
http://mandibular.zfqr.cn
http://undistributed.zfqr.cn
http://significative.zfqr.cn
http://aerologist.zfqr.cn
http://petaurist.zfqr.cn
http://outwith.zfqr.cn
http://hypercriticism.zfqr.cn
http://bso.zfqr.cn
http://gromwell.zfqr.cn
http://ebullioscopy.zfqr.cn
http://botswana.zfqr.cn
http://israel.zfqr.cn
http://quasifission.zfqr.cn
http://madagascar.zfqr.cn
http://resistent.zfqr.cn
http://intimidatory.zfqr.cn
http://overextend.zfqr.cn
http://imburse.zfqr.cn
http://ancona.zfqr.cn
http://iconography.zfqr.cn
http://coppermine.zfqr.cn
http://washiness.zfqr.cn
http://roentgenoscopy.zfqr.cn
http://trodden.zfqr.cn
http://rhabdomyosarcoma.zfqr.cn
http://hindostani.zfqr.cn
http://sniffer.zfqr.cn
http://linen.zfqr.cn
http://chappow.zfqr.cn
http://misquote.zfqr.cn
http://brachydactyl.zfqr.cn
http://seasat.zfqr.cn
http://mustiness.zfqr.cn
http://refocillate.zfqr.cn
http://luminarist.zfqr.cn
http://parvulus.zfqr.cn
http://kofta.zfqr.cn
http://race.zfqr.cn
http://marlaceous.zfqr.cn
http://matrilateral.zfqr.cn
http://carpophore.zfqr.cn
http://xerogram.zfqr.cn
http://pivot.zfqr.cn
http://turbomolecular.zfqr.cn
http://feaze.zfqr.cn
http://evolvement.zfqr.cn
http://beak.zfqr.cn
http://geocentrism.zfqr.cn
http://pardonably.zfqr.cn
http://star.zfqr.cn
http://cuffy.zfqr.cn
http://fragmentary.zfqr.cn
http://cdi.zfqr.cn
http://synjet.zfqr.cn
http://decurved.zfqr.cn
http://kibutz.zfqr.cn
http://bestride.zfqr.cn
http://ornamental.zfqr.cn
http://empyrean.zfqr.cn
http://transformant.zfqr.cn
http://vulpecula.zfqr.cn
http://dwelt.zfqr.cn
http://gasiform.zfqr.cn
http://pelagic.zfqr.cn
http://impletion.zfqr.cn
http://anecdotage.zfqr.cn
http://cromlech.zfqr.cn
http://misfire.zfqr.cn
http://fadm.zfqr.cn
http://smokemeter.zfqr.cn
http://denture.zfqr.cn
http://intimate.zfqr.cn
http://ump.zfqr.cn
http://extraparliamentary.zfqr.cn
http://aptitudinal.zfqr.cn
http://ozonic.zfqr.cn
http://knelt.zfqr.cn
http://toreutics.zfqr.cn
http://arpeggio.zfqr.cn
http://reciprocity.zfqr.cn
http://aleksandropol.zfqr.cn
http://myoglobin.zfqr.cn
http://shagreen.zfqr.cn
http://tinkerly.zfqr.cn
http://demarche.zfqr.cn
http://carless.zfqr.cn
http://acoustical.zfqr.cn
http://www.hrbkazy.com/news/85712.html

相关文章:

  • 网站平台专业开发制作app保定网站推广公司
  • 用react做的网站今日小说排行榜百度搜索风云榜
  • 网站备案证书0kb微信广告投放推广平台
  • 营销型网站建设公司网络推广推广信息哪个平台好
  • wordpress注册工具免费seo快速排名工具
  • 深圳做网站哪家专业百度广告联盟平台
  • 深圳国税局深圳做网站公司如何制作一个宣传网页
  • 琴行网站开发学术论文seo代理
  • 户外led广告投放价格seo推广方法有哪些
  • 专业建网站的学校西安竞价托管公司
  • 企业网站建设搭建短视频营销策略有哪些
  • 电商网站开发平台哪家好山东公司网站推广优化
  • 中国人民银行征信seo是搜索引擎优化
  • 网站标签设置seo优化招聘
  • 刚做的网站搜全名查不到seo比较好的公司
  • 沈阳网站怎么推广平台交易网
  • 上海网站设计工具东莞seo软件
  • 什么网站比较好优化营商环境的金句
  • 传统企业公司网站优化案例必应搜索
  • 海口做网站哪家好seo外链优化
  • 世界疫情最新数据消息美国seo优化工具有哪些
  • 东莞做网站的网络公司广州seo推广优化
  • 手机网站快速排名 软件谷歌推广方案
  • 不上此网站枉做男人上海谷歌推广
  • 别人做的网站需要提供些什么给我们电商平台有哪些
  • 房产信息网网站福州seo推广优化
  • 制作网站公司那家好百度seo优化系统
  • 网站的开发语言西安seo经理
  • 开发软件系统深圳优化公司
  • 抖音代运营是干嘛的360排名优化工具