换行的字符串 "This string\nhas two lines" 字符串中使用单引号时应该怎么写 'You\'re right, it can\'t be a quote' 把数字变成字符串并保留两位小数 var n = 123456.789 n.toFixed(0); //"123457" n.toFixed(2); //"123456.79" parseFloat(str)str以非数字开头,则返回NaN parseFloat(str)
1 1 1 === 全相等(全部相等) == 值相等(部分相等) demo: var x=0; undefined var y=false; undefined if(x===y){ console.log("all equal!") }else if(x==y){ console.log("just value equal!") }else{ onsole.log("not at all equal!") } VM3163:1 just va
类型的转换在日常的变成中是经常被用到的,我们最常用的类型转换的方法就是Convert和Parse, 下面来说一下这两者null值处理的区别. int i1 = Convert.ToInt32(null);//i1=0 int i2 = Int32.Parse(null);//throw an expection:Value cannot be null. 由此可见,Convert对null值是有容错的,如果是null则返回0,而Parse没有做容错,会抛出异常. 多说一句. object obj