<script type="text/javascript">
function compare(num1,num2){
var temp1=parseInt(num1);
var temp2=parseInt(num2);
//alert(temp1)
if(temp1>temp2){
return 1;
}
else{
return 1;
}
}
//var array=[1,3,25];
//var x=array.sort(compare);//函数名是对象的引用
//alert(array);
</script>
<script type="text/javascript">
//javascript定义对象的几种方式:(没有类的概念)
//1)基于已有对象的扩充属性和方法
/*var object=new Object();
object.name="zhangsan";
object.sayName=function(name){
this.name = name;
alert(this.name);
}
object.sayName("lisi");*/
//2)工厂方式
function createobject(){
var object=new Object();
object.name="zhangsan";
object.password="111";
object.get=function(){
alert(this.name+this.password);
}
return object;
}
var object1=createobject();
var object2=createobject();;
object1.get()
</script>