Prepare for the Salesforce JavaScript Developer Exam. Utilize comprehensive quizzes, flashcards, and multiple choice questions with hints and explanations. Boost your exam readiness!

Practice this question and more.


What will Object.keys(emp) return if emp = {name: "Santanu", dept: "IT"}?

  1. Array ["name", "dept"]

  2. Object {name: "Santanu", dept: "IT"}

  3. String "name, dept"

  4. Object.keys is not usable on emp

The correct answer is: Array ["name", "dept"]

When calling `Object.keys(emp)` where `emp` is defined as `{name: "Santanu", dept: "IT"}`, the method will return an array containing the property names of the `emp` object. In this case, the properties are `name` and `dept`. The `Object.keys()` method retrieves an array of a given object's own enumerable property names in the same order that they would be iterated with a `for...in` loop. Since `emp` contains two properties, the output will be an array: `["name", "dept"]`. This precisely matches the given answer choice, making it the correct response to the question. The other options either represent different data structures or formats that are not applicable in this context.