六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 6|回复: 0

JavaScript 中两种类型的全局对象/函数

[复制链接]

升级  16.15%

427

主题

427

主题

427

主题

探花

Rank: 6Rank: 6

积分
1323
 楼主| 发表于 2013-1-29 09:29:53 | 显示全部楼层 |阅读模式
一、核心JavaScript内置对象,即ECMAScript实现提供的不依赖于宿主环境的对象
  这些对象在程序执行之前就已经(实例化)存在了。ECMAScript称为The Global Object,分为以下几种:
  1, 值属性的全局对象(Value Properties of the Global Object)。有NaN,Infinity,undefined。
  2, 函数属性的全局对象(Function Properties of the Global Object)。有eval,parseInt,parseFloat,isNaN,isFinite,decodeURI,encodedURI,encodeURIComponent
  3,构造器(类)属性的全局对象(Constructor Properties of the Global Object)。有Object,Function,Array,String,Boolean,Number,Date,RegExp,Error,EvalError,
RangeError,ReferenceError,SyntaxError,TypeError,URIError。
  4,其它属性的全局对象(Other Properties of the Global Object),可以看出成是Java中的静态类,可以直接用类名+点号+方法名使用。有Math,JSON。
  ECMAScript规范提到这些全局对象(The Global Object)是具有Writable属性的,即Writable为true,枚举性(Enumerable)为false,即不能用for in枚举。ECMAScript有这么一段:


  Unless otherwise specified, the standard built-in properties of the global object have attributes {[[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}.
  虽然规范提到The Global Object是可以被重写的,但不会有谁去重写它们的。这里仅仅做个测试。
<div class="cnblogs_code">NaN    = 11;eval   = 22;Object = 33;Math   = 44;alert(NaN);alert(eval);alert(Object);alert(Math);
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表