如何在javascript中使用类型变量? [英] How to use typed variables in javascript?

查看:60
本文介绍了如何在javascript中使用类型变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在javascript中使用类型变量?像integer,string,float ...

Is there any way to use typed variables in javascript? Like integer, string, float...

推荐答案

不输入JavaScript变量。

JavaScript variables are not typed.

JavaScript值是。相同的变量可以更改(分配一个新值),例如,从未初始化到数字到布尔到字符串(不是你想要这样做!):

JavaScript values are, though. The same variable can change (be assigned a new value), for example, from uninitialized to number to boolean to string (not that you'd want to do this!):

var x;       // undefined
x = 0;       // number
x = true;    // boolean
x = "hello"; // string

这篇关于如何在javascript中使用类型变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆