当前位置:首页 > 千层云服务器 > 正文

javascript对象属性有哪些

javascript中的对象属性有:1.constructor,返回对创建此对象的数组函数的引用;2.isPrototypeOf,检查传入对象是否是当前对象的原型;3.valueOf,返回对象的字符串、数值或布尔值表示;

javascript对象属性有哪些

javascript中的对象属性有以下几种

1.constructor属性

javascript中constructor属性的作用是用于返回对创建此对象的数组函数的引用。

constructor属性语法:

object.constructor

constructor属性使用方法:

var test=new Array();

if (test.constructor==Array)

{

document.write("This is an Array");

}

if (test.constructor==Boolean)

{

document.write("This is a Boolean");

}

输出结果为:

This is an Array

2.isPrototypeOf属性

javascript中isPrototypeOf属性的作用是用于检查传入的对象是否是当前对象的原型。

isPrototypeOf属性语法:

function.prototype.isPrototypeOf(object)

isPrototypeOf属性使用方法:

function test(){

var re = new RegExp(); //初始化变量。

return (RegExp.prototype.isPrototypeOf(re)); //返回 true。

}

3.valueOf属性

javascript中valueOf属性的作用是用于返回对象的字符串、数值或布尔值表示。

valueOf属性语法:

NumberObject.valueOf()

valueOf属性使用方法:

var str="Hello world!";

document.write(str.valueOf());

如果您对该产品感兴趣,请填写办理(客服微信:xiaoxiongyidong)

为您推荐:

发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

在线客服