COMPUTER PROGRAMMING FUNDAMENTALS
WHAT IS PROGRAMMING
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
pumpkin.push({eyes:‘green’});
|
|
pumpkin[eyes] = ‘green’;
|
|
pumpkin.eyes = ‘green’;
|
|
var pumpkin.eyes = ‘green’
|
Detailed explanation-1: -JavaScript will return ‘undefined’ if we try to access properties or call methods that do not exist in the given object.
Detailed explanation-2: -Using the assign () method In JavaScript, assign() is an in-built method. Using the assign() method, we can assign or add a new value to an existing object or we can create the new object without changing the existing object values.
Detailed explanation-3: -Which of the following code creates an object? Explanation: var book = new Object(); will create an object.
Detailed explanation-4: -Some of the ways to add a property to an object JavaScript include: using dot notation, using bracket [ ] notation, using the defineProperty() method, using the spread operator, and using the Object. assign() method.