Javascript类型

var y = x.toString(2);

转换2进制

var y = (257).toString(0x10);

转换16进制

var a = true;

if(a == 1){

alert('aaa');

}

可以alert 。

(In fact, JavaScriptdoes just this and converts true and false to 1 and 0 when necessary.)

var point = { x:2.3, y:-1.2 };Object声明

An important featureof JavaScript is that functions are values that can be manipulated byJavaScript code. In many languages, including Java, functions are only asyntactic feature of the language -- they can be defined and invoked, but theyare not data types. The fact that functions are true values in JavaScript givesa lot of flexibility to the language. It means that functions can be stored invariables, arrays, and objects, and it means that functions can be passed asarguments to other functions. This can quite often be useful. We'll learn moreabout defining and invoking functions, and also about using them as data values

function是一个数据类型。

This comparison istrue either if the my.prop property does not exist or if it does exist butcontains the value null. Since both null and the undefined value indicate anabsence of value, this equality is often what we want. However, if you trulymust distinguish between a null value and an undefined value, use the ===identity operator or the typeof operator

UndefinedNull之间比较==会返回true

var len = s.length;

In this case, sremains a string; the original string value itself is not changed. A newtransient String object is created, which allows us to access the lengthproperty, and then the transient object is discarded, with no change to theoriginal value s. If you think this scheme sounds elegant and bizarrely complexat the same time, you are right. Typically, however, JavaScript implementationsperform this internal conversion very efficiently, and it is not something youshould worry about.

自动创建一个对象,调用方法后自动discard


var s = "helloworld";              // A primitivestring value

var S = newString("Hello World");  // AString object



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值