溫馨提示×

javascript對象屬性有哪些

養魚的貓咪
354
2021-04-13 14:49:19
欄目: 編程語言

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());

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女