== JS-4-数据类型 ==
== JS-4-数据类型 ==
typeof 关键字检测类型
.length() 方法 检测长度
-Number-
parseInt()
parseFloat()isNaN()
-String-
str.charAt(2);
parseInt('100px'); // 100
-object-
{} [] window document给对象添加 (原则上可以给任何非空对象添加属性和方法)
属性
window.jq = 'jq'
方法
window.$ = function(){ console.log('jq') }
调用 $();
-JSON 对象-
var json = {num:1, name:2, age:19}注意json的名称规则
var json = {admin:'silver', user:'admin', password:'12345', 'fire-fox':1}
undefined
var json = {admin:'silver', user:'admin', password:'12345', fire-fox:1}
VM266:2 Uncaught SyntaxError: Unexpected token -(…)
NULLUndefined
-- 隐式类型转换 --

浙公网安备 33010602011771号