Object.constructor###

object.constructor

a = new Array(1,2,3); // Create an object
a.constructor == Array // Evaluates to true

Object.create()###

Object.create(proto); Object.create(proto, descriptors)

// Create an object that has own properties x and y and inherits property z
var p = Object.create({z:0}, {
x: { value: 1, writable: false, enumerable:true, configurable: true},
y: { value: 2, writable: false, enumerable:true, configurable: true},
});

Object.defineProperties()###

Object.defineProperties(o, descriptors)

// Add read-only properties x and y to a newly-created object
var p = Object.defineProperties({}, {
x: { value: 0, writable: false, enumerable:true, configurable: true},
y: { value: 1, writable: false, enumerable:true, configurable: true},
});

Object.defineProperty()

Object.defineProperty(o, name, desc)

function constant(o, n, v) { // Define a constant o.n with value v
Object.defineProperty(o, n, { value: v, writable: false
enumerable: true, configurable:false});
}

Object.getOwnPropertyDescriptor()

Object.getOwnPropertyDescriptor(o, name)

The descriptor for a data property looks like this:
{
value: /* any JavaScript value */,
writable: /* true or false */,
enumerable: /* true or false */,
configurable: /* true or false */
}
The descriptor for an accessor property looks like this:
{
get: /* function or undefined: replaces the property value */,
set: /* function or undefined: replaces the writable attribute */,
enumerable: /* true or false */,
configurable: /* true or false */
}

Object.getOwnPropertyNames()

Object.getOwnPropertyNames(o)

Object.getOwnPropertyNames([]) // => ["length"]: "length" is non-enumerable

Object.getPrototypeOf()

Object.getPrototypeOf(o)

var p = {}; // An ordinary object
Object.getPrototypeOf(p) // => Object.prototype
var o = Object.create(p) // An object that inherits from p
Object.getPrototypeOf(o) // => p

Object.hasOwnProperty()###

object.hasOwnProperty(propname)

var o = new Object(); // Create an object
o.x = 3.14; // Define a noninherited local property
o.hasOwnProperty("x"); // Returns true: x is a local property of o
o.hasOwnProperty("y"); // Returns false: o doesn't have a property y
o.hasOwnProperty("toString"); // Returns false: toString property is inherited

Object.isPrototypeOf()###

object.isPrototypeOf(o)

var o = new Object(); // Create an object
Object.prototype.isPrototypeOf(o) // true: o is an object
Function.prototype.isPrototypeOf(o.toString); // true: toString is a function
Array.prototype.isPrototypeOf([1,2,3]); // true: [1,2,3] is an array
// Here is a way to perform a similar test
(o.constructor == Object); // true: o was created with Object() constructor
(o.toString.constructor == Function); // true: o.toString is a function
// Prototype objects themselves have prototypes. The following call
// returns true, showing that function objects inherit properties
// from Function.prototype and also from Object.prototype.
Object.prototype.isPrototypeOf(Function.prototype);

Object.keys()###

Object.keys(o)

Object.keys({x:1, y:2}) // => ["x", "y"]

Object.propertyIsEnumerable()###

object.propertyIsEnumerable(propname)

var o = new Object(); // Create an object
o.x = 3.14; // Define a property
o.propertyIsEnumerable("x"); // true: property x is local and enumerable
o.propertyIsEnumerable("y"); // false: o doesn't have a property y
o.propertyIsEnumerable("toString"); // false: toString property is inherited
Object.prototype.propertyIsEnumerable("toString"); // false: nonenumerable

js:方法3. 对象的更多相关文章

  1. (转)Silverlight调用的JS方法返回对象数组的处理方法

    最近在做Silverlight应用,需要用Silverlight调用页面中Javascript方法.这 个JS方法返回一个对象数组给Silverlight.对于这个对象数组怎么在Silverlight ...

  2. js方法在对象中的状态

    在C#中,只有对象的字段存储在堆中,而方法则存储在一个方法表中.当实例化多个对象时,为字段分配了内存空间,而方法都指向一个方法表中的同一个方法. 如 而在JS中,字段和方法都属于值类型,都存储在堆中. ...

  3. js方法传入对象;js方法传入方法;js方法回调 callback

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  4. JS中的对象和方法简单剖析

    众所周知,在js中对象就是精髓,不理解对象就是不理解js. 那么什么事js中的对象呢? 在js中,几乎一切皆对象: Boolean ,String,Number可以是对象(或者说原生数据被认作对象): ...

  5. 关于js函数,方法,对象实例的一些说明

    朋友们大家好,好久没有更新文章了,最近正好有空就想着写点什么吧,加上这段时间总是能听到一些朋友们问关于js函数,方法,对象实例到底有什么区别这个问题,所以今天就献丑来简单说明一些吧! 其实这些主要都是 ...

  6. js对数组对象的操作以及方法的使用

    js对数组对象的操作以及方法的使用 如何声明创建一个数组对象: var arr = new Array(); 或者 var arr = []; 如何移除所有数组中数据? arrayJson.dataL ...

  7. js之global 对象 方法

    global 作为js的全局对象,但其是无法直接访问的,但是在浏览器中浏览器是将这个对象当做是window对象的一部分,即Date 等Global的属性使用window.Date 可访问到 1.url ...

  8. 拼接的html的onclick事件中无法传递对象给js方法的处理办法

    如下: 拼接的html: " onclick=\"valDocName2('"+JSON.stringify(doc).replace(new RegExp(" ...

  9. JS类、对象、方法、prototype、_proto_

    案例代码: function People(name) { //对象属性 this.name = name; //对象方法 this.Introduce = function() { alert(&q ...

随机推荐

  1. ocx文件转换成C#程序引用的DLL

    将ocx文件转换成C#程序引用的DLL文件的办法  将ocx文件转换成C#程序引用的DLL文件的办法,需要的朋友可以参考一下  1.打开VS2008或VS2010命令提示符(此例用VS2008) 将o ...

  2. css 自动换行 [英文、数字、中文]

    white-space:normal;overflow: auto;table-layout:fixed; word-break: break-all;

  3. 在某公司时的java开发环境配置文档

    1 开发环境配置 1.1.  MyEclipse 配置 1.MyEclipse下载地址:\\server\共享文件\backup\MyEclipse9.0 2.修改工作空间编码为UTF-8,如下图 3 ...

  4. UVA 10192 Vacation

    裸最长公共子序列 #include<time.h> #include <cstdio> #include <iostream> #include<algori ...

  5. python中的时间处理函数

    Python提供了多个内置模块用于操作日期时间,像calendar,time,datetime.time模块我在之前的文章已经有所介绍,它提供 的接口与C标准库time.h基本一致.相比于time模块 ...

  6. 公众号开发——测试工具【ngrok】

    工具下载:ngrok 目录清单: ngrok.exe ngrok.cfg run.bat 点击bat启动. 可修改域名,右键bat文件修改. 成功效果图: 注:80端口被占用了怎么办?    ——   ...

  7. sdut 2449走迷宫【最简单的dfs应用】

    走迷宫 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_ 题目描述 一个由n * m 个格子组成的迷宫,起点是(1, 1), 终点是(n, m) ...

  8. hdu 1251:统计难题(字典树,经典题)

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others)Total Submi ...

  9. macosx安装MySQLdb

    折腾了半天,记录一下. 先按照这个步骤安装mysql-python 如果python setup.py install 时候出现clang 错误,运行 python -E setup.py insta ...

  10. C# SMTP邮件发送 分类: C# 2014-07-13 19:10 334人阅读 评论(1) 收藏

    邮件发送在网站应用程序中经常会用到,包括您现在看到的博客,在添加评论后,系统会自动发送邮件通知到我邮箱的,把系统发送邮件的功能整理了下,做了一个客户端Demo,希望对有需要的童鞋有所帮助: 核心代码: ...