下列方法中,能正确创建 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})
举一反三
- 下列方法中,能正确创建 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")