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. bootstrap日期控件在火狐下的模态框中选择时间下拉菜单无效的解决办法

    今天收到程序组提交的一个兼容BUG,在火狐中使用模态框加载日期控件时选择时间下拉菜单没有效果(不能点击),而在谷歌中却是好的, 排错思路:1,在当前页面主层放置一个时间控件,测试通过 2,在ajax加 ...

  2. chrome进入控制台时自动进入断点模式的解决方法

    简单粗暴,不知道为什么,去掉那个√就好了

  3. 多线程编程4 - NSOperationQueue

    一.简介 一个NSOperation对象可以通过调用start方法来执行任务,默认是同步执行的.也可以将NSOperation添加到一个NSOperationQueue(操作队列)中去执行,而且是异步 ...

  4. idea 用maven骨架生成项目速度慢的问题

    使用mvn archetype:generate命令时,加上-DarchetypeCatalog=local archetypeCatalog=local

  5. UVa1592_数据库

    #include<iostream> #include<cstdio> #include<vector> #include<utility> #incl ...

  6. class-dump获取iOS私有api

    转自:http://blog.csdn.net/sunyuanyang625/article/details/41440167 获取各类iOS私有api 安装工具class-dump 资源地址http ...

  7. Orleans是什么 (一)

    官网:http://dotnet.github.io/orleans/ 文档:http://dotnet.github.io/orleans/What's-new-in-Orleans 源码:http ...

  8. Apache commons-dbutils笔记

  9. 二、JavaScript语言--JS实践--商城分类导航效果

    商城类导航菜单制作(以京东为例--竖向列表横向伸缩) 可以用两种方式来实现:用CSS实现和用JS实现 方法一:用CSS实现(要点:使用hover) <!DOCTYPE html PUBLIC & ...

  10. sys.sysprocesses视图的使用小结

    Sys.SysProcesses 系统表是一个很重要的系统视图,主要用来定位与解决Sql Server的阻塞和死锁包含正在 SQL Server 实例上运行的进程的相关信息.这些进程可以是客户端进程或 ...