当前位置:网站首页>Part 31 supplement (31) ECMAScript conversion to string and number
Part 31 supplement (31) ECMAScript conversion to string and number
2022-06-27 16:59:00 【Embedded workplace】
1、 Convert to string
// Convert to string// If no cardinality is specified ,toString() All output in decimal system ;
2、 Convert to numbers
// Convert to numbers//parseInt(): Convert the value to an integer ;//parseFloat(): Convert a value to a floating point number ;// Both methods can only be used for String type , Return values of other types are NaN;
3、 Code
import QtQuick 2.9
import QtQuick.Window 2.2
Window {
visible: true
width: 640
height: 480
Component.onCompleted: {
// Convert to string
// If no cardinality is specified ,toString() All output in decimal system ;
var name = "fjf"
console.log(name.toString())
var age = 22
console.log(age.toString(2))
var isIf = false
console.log(isIf.toString())
// Convert to numbers
//parseInt(): Convert the value to an integer ;
//parseFloat(): Convert a value to a floating point number ;
// Both methods can only be used for String type , Return values of other types are NaN;
var num1 = parseInt("3.1415")
console.log(num1)
var num2 = parseFloat("3.1415")
console.log(num2)
}
}
边栏推荐
- Huawei cloud devcloud launched four new capabilities, setting two domestic firsts
- Cesium realizes satellite orbit detour
- 防火墙基础之源NAT地址转换和服务器映射web页面配置
- [fxcg] today's market analysis
- 智慧风电 | 图扑软件数字孪生风机设备,3D 可视化智能运维
- C language teacher workload management system
- d3dx9_ What if 27.dll is lost? d3dx9_ How to repair 27.dll?
- 黑马程序员-软件测试基础班-02-30-45工具代开浏览器运行代码,音、视频、测试点,音视频标签,布局标签。超链接语法进阶,绝对路径,相对路径
- Kubernetes basic self-study series | introduction to ingress API
- d3dx9_ How to repair 33.dll? d3dx9_ What if 33.dll is lost?
猜你喜欢
A large number of missing anchor text
What is the level 3 password complexity of ISO? How often is it replaced?
Hierarchical clustering and case analysis
防火墙基础之源NAT地址转换和服务器映射web页面配置
ROS "topic" programming implementation
How to improve it electronic equipment performance management
软件测试学习-黑马程序员,软件测试学习大纲
Etcd visualization tool: kstone deployment (I), rapid deployment based on Helm
Leetcode 33. Search rotation sort array
Why should string be designed to be immutable?
随机推荐
10分钟掌握mysql的安装步骤
事务的隔离级别详解
leetcode 200. Number of islands
特殊函数计算器
印象深刻的问题
Community sharing jumpserver in the eyes of senior open source users: a fortress machine for "Crazy" iteration
C語言教師工作量管理系統
d3dx9_ How to repair 38.dll? d3dx9_ 38. How to download a missing DLL?
Handling method of occasional error reporting on overseas equipment
2/14 preliminary calculation geometry
QT5 之信号与槽机制(演示控件自带的信号与槽函数关联)
[the way of programmer training] - 3 Character count statistics
Cesium realizes satellite orbit detour
About how vs2019c # establishes the login interface, the user name and password entered must match the records in the access database
Oracle concept II
Mode setting of pulseaudio (21)
Practice of constructing ten billion relationship knowledge map based on Nebula graph
Determine the maximum number of specific words in a string
Delete duplicate elements in the sorting linked list
07. Express routing