下列方法中,能正确创建 JavaScript 对象的是( )。
A: var txt = new Object[name:"George",price:25]
B: var txt = new Object(name:"George",price:25)
C: var txt = new Object{name:"George",price:25}
D: var txt = new Object({name:"George",price:25})
A: var txt = new Object[name:"George",price:25]
B: var txt = new Object(name:"George",price:25)
C: var txt = new Object{name:"George",price:25}
D: var txt = new Object({name:"George",price:25})
D
举一反三
- 下列方法中,能正确创建 JavaScript 对象的是( )。 A: var txt = new Object[name:"George",price:25] B: var txt = new Object(name:"George",price:25) C: var txt = new Object{name:"George",price:25} D: var txt = new Object({name:"George",price:25})
- 以下能够创建一个对象的是( )。 A: var obj=new Object( ) ; B: var obj=function(name){this.name=name ; }<br> var p1=new obj( "张三" ) ; C: var obj={ name : "张三" ; } D: var obj=Object.create( { name: "张三" } ) ;
- 下列JavaScript定义对象的语句中,()不正确。 A: var person = {}; B: var person = new Object(); C: person =name; D: function person(name,sex){} var personObj = new person();
- 下列选项中,定义JavaScript 数组的方法不正确的是( ) A: var arr =new Array(); B: var arr =new Array(4); C: var arr =new Array("George","John","Thomas"); D: var arr=new Array[3];
- 实现创建一个 JavaScript 数组的语法是 _________ A: var txt = newArray("tim","kim","jim") B: var txt = newArray(1:"tim",2:"kim",3:"jim") C: var txt = new Array="tim","kim","jim" D: var txt = newArray:1=("tim")2=("kim")3=("jim")
内容
- 0
下面不是用于创建一个新的对象的语句是 A: var d = new Date(); B: var f = (); C: var o = new Object(); D: var o = {title: "hello", author: "Tom"};
- 1
以下哪项可以实现对象的定义? A: var obj=[]; B: var obj={}; C: var obj=new Object(); D: var obj=123;
- 2
var arr = new Array(); var arr[2]="name"; alert(arr)的结果是什么
- 3
请使用new Object()方式创建一个空对象,并为该对象添加如下成员,姓名:张三;性别:男;年龄:30。 代码如下: var obj = new Object(); ________= '张三'; obj.sex = ______; ________= 30;
- 4
下列代码[br][/br] 1 2 3 4 5 6 7 var person={fname:"John",lname:"Doe",age:25}; var txt=""; for (x in person) { txt=txt + person[x]; } alert(txt); 输出为? A: JohnDoe25 B: fname:"John",lname:"Doe",age:25 C: fname:John,lname:Doe,age:25 D: fnamelnameage