杂七杂八js

1. js可以放在html的<head></head>标签之间,也可以放在<body></body>之间,前面一种较常用

2.通过”use strict”来打开严格模式,例如:

function dosomething(){
"use strict"
//code here
}

3. js的六种数据类型:Number,String,Boolean,Null,undefined,Object,此外还有几种参考类型

4. 使用函数document.writ()来打印输出

5. js中的变量不是强类型的,因此可以被多次分配为不同类型的值

var x = 4;
x = "Yuki";

6. 相等(==)和严格相等(===)
例如:x = 42; y = “42”,有x==y,但没有x===y;

7. js中创建对象的方式,注意是直接创建对象
第一种:var star = {};
第二种:var star = new Object;
然后可以直接给对象添加和设置属性:
star.name = “polaris”;
star.constellation = “ursa minor”

你可能感兴趣的:(JavaScript)