/*定义一个变量*/
var str="abc";
//值为abc
console.log("str="+str);
//类型为String
console.log("str type is "+typeof str);
/*定义一个变量*/
var str1;
//值未undefined
console.log("str1="+ str1);
//值undefined 但是不会报错
//报错
console.log(str2);
//定义对象 并给属性赋值
var person=new Object();
person.name='huahua';
person.age=23;
console.log("person typeof is "+typeof person);
console.log("name:"+ person.name+"\t age:"+person.age);
//定义对象 并给属性赋值
var man={name:'zhangsan',age:33};
console.log("man typeof is "+typeof man);
console.log("name:"+ man.name+"\t age:"+man.age);
//注意这是字符串 不是对象
var woman="{name:'lihuan',age:24}";
console.log("woman typeof is "+typeof woman);
console.log("name:"+ woman.name+"\t age:"+woman.age);
/*定义函数 无参*/
var test=function(){
console.log("this is test function");
}
/*定义函数 无参*/
function test1(){
console.log("this is test1 function");
}
/*定义函数 有参*/
function test2(a){
console.log("this is test2 function and param is "+a);
}
/*定义函数 有参*/
var test3=function(b){
console.log("this is test3 function and param is "+b);
}
//当文档内容完全加载完成会触发该事件
window.οnlοad=function(){
console.log("this is onload function");
test();
test1();
test2('a');
test3('b');
}
/*定义一个变量*/var str="abc";//值为abcconsole.log("str="+str);//类型为Stringconsole.log("str type is "+typeof str); /*定义一个变量*/var str1;//值未undefinedconsole.log("str1="+ str1);//值undefined 但是不会报错//报错...