Which line of code should you use?

You are developing an application in HTML5.
You have the following code.

You need to add an additional property to the function definition.
Which line of code should you use?

You are developing an application in HTML5.
You have the following code.

You need to add an additional property to the function definition.
Which line of code should you use?

A.
NewOrder [“newProperty”] = “newProperty”

B.
NewOrder. prototype. newProperty = “newProperty”

C.
this.NewOrder. newProperty = “newProperty”

D.
NewOrder. newProperty = “newProperty”

Explanation:
http://www.w3schools.com/js/js_object_prototypes.asp



Leave a Reply 12

Your email address will not be published. Required fields are marked *

three × one =


asdf

asdf

i really this the right answer is B
can anyone tell me if i am right and if not why?

puvpul

puvpul

asdf is right answer should be B.

Noor

Noor

The correct answer is B

mrq

mrq

why not d?

Diezvai

Diezvai

As I understood – NewOrder is an object prototype, not existing object. If new object would be created (var myOrder = new NewOrder(1,01-01-2017 10:15); ) and that object needs new property, then yes – answer would be D.

Sergiu

Sergiu

B is the answer.

G

G

I mean that the question is not clear. We can use prototype and normal object extension.
If we use prototype the additional property is permanent, also for future object instances.
If we use normal extensions the additional property is only for that object.

Repo

Repo

yes, it’s b or d.
B is more correct.

Repo

Repo

C is wrong for sure!