1. JavaScript对大小写敏感。
2. JavaScript是脚本语言。浏览器会在读取代码时,逐行地执行脚本代码。而对于传统编程来说,会在执行前对所有代码进行编译。
3. 变量什么用var, 是弱类型。
JavaScript数据类型:数字、字符串、布尔、数组、对象、null、undefined
JavaScript变量均为对象。当你声明一个变量时,就创建了一个新的对象。
<!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> </head> <body> <script> document.write("Hello World" + "</br>"); var x;// undefined var n = null;//null var y = 6;//数字 var f = 3.1415;//浮点数 var s = "Hello World";//字符串 var carname = '大众';//也可以单引号 var answer1 = "He is called 'yoyo'"; var answer2 = 'He is called"yoyo"'; var b = true;//bool型 //JavaScript变量均为对象,当您声明一个变量时,就创建了一个新的对象 var z1 = new Number; var z2 = new String; var z3 = new Boolean; var z4 = new Array; var z5 = new Object; //数组 var cars1 = new Array(); cars1[0] = "Audi"; cars1[1] = "BMW"; cars1[2] = "Volvo"; var cars2 = new Array("Audi", "BMW", "Volvo"); var cars3 = ["Audi", "BMW", "Volvo"]; //对象:对象由花括号分隔。在括号内部,对象的属性以名称和值对的形式来定义 var person = { firstname: "yoyo", lastname: "xiao", id: 506 }; document.write(x + "</br>"); document.write(n+ "</br>"); document.write(y + "</br>"); document.write(f + "</br>"); document.write(s + "</br>"); document.write(carname + "</br>"); document.write(answer1 + "</br>"); document.write(answer2 + "</br>"); document.write(b + "</br>"); document.write(z1 + "</br>"); document.write(z2 + "</br>"); document.write(z3 + "</br>"); document.write(z4 + "</br>"); document.write(z5 + "</br>"); for (i = 0; i < cars3.length;i++) { document.write(cars3[i] + "</br>"); } document.write(person.firstname + "</br>"); document.write(person["lastname"] + "</br>"); </script> </body> </html>