boolean
java中:
boolean a = new Boolean(arg).booleanValue()
只有参数值arg.toLowerCase()为"true"时,表达式为真,例如"true", "tRue"
javascript中:
All the following lines of code create Boolean objects with an initial value of false:
var myBoolean=new Boolean()
var myBoolean=new Boolean(0)
var myBoolean=new Boolean(null)
var myBoolean=new Boolean("")
var myBoolean=new Boolean(false)
var myBoolean=new Boolean(NaN)
--------------------------------------------------------
split
Java:
split: 从右边第一个不是空字符""的算起,空格" "也是一个字符。
String s = ";;"; //0
// String s = ";; "; //3
// String s = "; ;"; //2
// String s = " ;;"; //1
// String s = "test"; // 1. sub[0]= "test" (不含有";"分隔符)
String[] sub = s.split(";"); System.out.println(sub.length);
Javascript:
var s = ";;" //3
var s = "test"; //1.
var strArray = s.split(";") alert(strArray.length)
----------------------------------------------------------------------
substring
Java:
//if (beginIndex < 0 || endIndex > count || beginIndex > endIndex) throw new StringIndexOutOfBoundsException
String s = "test";
String sub = s.substring(0,1); "t"
String sub = s.substring(1,1); //""
String sub = s.substring(4); //(一个参数时,作为左边界)
Javascript:
// 两个参数无论大小,没有关系,而且可以越界
var s = "test"
n = s.substring(1,1); // ""
n = s.substring(1,2); // "e"
n = s.substring(1,0); // "t"
n = s.substring(1,-1); // "t"
n = s.substring(-1,-1); // ""
n = s.substring(-1,1) // "t"
n = s.substring(-1,9) //"test"
n = s.substring (-1) //--------------"test"(一个参数时,作为左边界)
n = s.substring(9) //---------------""