'Why does JavaScript object constructer prints only the first parameter value
var employee = ["Sam", "John", "Mark", "Peter", "Simon"]
var department = ["Sales", "Marketting", "Operation", "Finance", "Tech"]
var salary = [40000, 60000, 50000, 60000, 70000]
const data=new Object(department,employee,salary);
console.log(data);
Why only print departments value?
Solution 1:[1]
var employee = ["Sam", "John", "Mark", "Peter", "Simon"]
var department = ["Sales", "Marketting", "Operation", "Finance", "Tech"]
var salary = [40000, 60000, 50000, 60000, 70000]
const data={department,employee,salary};
console.log(data)
Solution 2:[2]
Enclose the values by curly braces
const data = {department, employee, salary};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | krystallix |
| Solution 2 | General Grievance |
