* 一、转化为数字*/
console.log(‘123123’*1.0);

/* 二、从一个值中提取另一中类型的值,并完成转化工作 */
console.log(parseInt(‘1233zxhag’)); //1233
console.log(parseFloat(‘1.123aef’)); //1.123
console.log(eval(1+123)); //124
console.log(toString(123)); //[object Window] ‘123’

/* 将整个值从一种类型转化成另一种类型(称作基本类型转换) */
console.log(String(‘123123′));
console.log(String(null)); //null
console.log(String(undefined)); //undefined
console.log(Number(‘123123′));
console.log(Number(null)); // 0
console.log(Number(undefined)); //NaN
console.log(Boolean(123123)); //true
console.log(Boolean(null)); //false
console.log(Boolean(undefined)); //false

本文转自(http://dayney.com/?p=38)

js中关于数据类型的转换的更多相关文章

  1. js中的数据类型及其转换

    Js中的数据类型 Js中的数据类型一共有六种,即number,string,boolean,underfine,null,object. 一,number Number数据类型指的是数字,可以为整型, ...

  2. JS中的数据类型和转换

    一.JS中的数据类型 js中的数据类型可以分为五种:number .string .boolean. underfine .null. number:数字类型 ,整型浮点型都包括. string:字符 ...

  3. js中的数据类型以及转换

    Js中的数据类型 Js中的数据类型一共有六种,即number,string,boolean,underfine,null,object. 一,number Number数据类型指的是数字,可以为整型, ...

  4. JS中的数据类型及转换

    js的六大类型 js中有六种数据类型,Boolean: 布尔类型 Number:数字(整数int,浮点数float ) String:字符串 Object:对象 (包含Array数组 ) 特殊数据类型 ...

  5. js中的数据类型

    JS中的数据类型: ——数字  (number)NaN ——字符串(string) ——布尔  (boolean)——函数  (function)     也是对象的一种 ——对象  (object) ...

  6. Javascript高级编程学习笔记(3)—— JS中的数据类型(1)

    前一段时间由于事情比较多,所以笔记耽搁了一段时间,从这一篇开始我会尽快写完这个系列. 文章中有什么不足之处,还望各位大佬指出. JS中的数据类型 上一篇中我写了有关JS引入的Script标签相关的东西 ...

  7. Js中的数据类型--String

    昼猫笔记--给你带来不一样的笔记 不止是笔记 更多的是思考 上一期咱们大概了解了下什么是JavaScript,想必大家也都知道 今天主要说下Js中的数据类型 在Js中一共分为六种数据类型 其中基本数据 ...

  8. 如何判断js中的数据类型?

    js六大数据类型:number.string.object.Boolean.null.undefined string: 由单引号或双引号来说明,如"string" number: ...

  9. 如何判断js中的数据类型

    如何判断js中的数据类型:typeof.instanceof. constructor. prototype方法比较 如何判断js中的类型呢,先举几个例子: var a = "iamstri ...

随机推荐

  1. Windows Message Codes

    https://www.autoitscript.com/autoit3/docs/appendix/WinMsgCodes.htm WM_ACTIVATE 0x0006 WM_ACTIVATEAPP ...

  2. ATSHA204加密认证IC

    The Atmel® ATSHA204 is a full turnkey security device. It includes a 4.5Kb EEPROM divided into 16 sl ...

  3. Apache-系统-网络部分配置

    参考了很多东西,但有些理解可能会有错误的地方,希望看到错误的地方可以即使纠正. 参考的内容. http://netsecurity.51cto.com/art/200608/30428.htm htt ...

  4. PhoneGap+jQuery Mobile+Rest 访问远程数据

    最近研究Mobile Web技术.发现了一个好东西-PhoneGap! 发现用PhoneGap+jQuery Mobile是一个很完美的组合! 本实例通俗易懂.适合广大开发人群:高富帅.白富美.矮穷戳 ...

  5. Codeforces Round #221 (Div. 1) B. Maximum Submatrix 2 dp排序

    B. Maximum Submatrix 2 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset ...

  6. Understanding Linux Kernel version 3 读书笔记

    P30, preemptive  kernel .kernel threading 和Multithreaded application support没太好理解,我想如果设计个多线程的程序来运行运行 ...

  7. MS WORD 表格自己主动调整列宽,自己主动变美丽,依据内容自己主动调整

    在MS WORD中,当有大量的表格出现时,调整每一个表格的的高和宽和大小将是一件很累的事情,拖来拖去,很耗时间,并且当WORD文档达到300页以上时,调整反应很的慢,每次拖拉线后,须要等待一段时间其才 ...

  8. Spring MVC 3.0 深入

    核心原理: . 用户发送请求给服务器.url:user.do . 服务器收到请求.发现DispatchServlet可以处理.于是调用DispatchServlet. . DispatchServle ...

  9. iOS开发——UI高级OC篇&自定义控件之调整按钮中子控件(图片和文字)的位置

    自定义控件之调整按钮中子控件(图片和文字)的位置 其实还有一种是在storyBoard中实现的,只需要设置对应空间的左右间距: 这里实现前面两种自定义的方式 一:imageRectForContent ...

  10. ios开发——实用技术篇Swift篇&照片选择

    照片选择 // MARK: - 选择照片 /*----- 选择照片 ------*/ @IBAction func addImageButtonClick() { let actionSheet = ...