Cannot access fruit before initialization

When creating an object and two class I am getting an error “Cannot access fruit before initialization”
#Code
fruit = {
apple: {
color: ‘red’,
price: 100
},
orange: {
color: ‘orange’,
price: 120
},
banana: {
color: ‘yellow’,
price: 40
}
}

console.log(fruit.apple.price)
console.log(fruit.orange.color)

class FruitClass {
constructor(color, price) {
this.color = color;
this.price = price;
}
}

let apple = new FruitClass(“red”, 100)
console.log(apple)

let fruit = class {
constructor(color, price) {
this.color = color;
this.price = price;
}
}

apple = new fruit(“red”, 100)
console.log(apple);

#Error
fruit = {
^

ReferenceError: Cannot access ‘fruit’ before initialization
at Object. (C:\web-dev\class-and-objects.js:3:7)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47

You already have a variable named fruit. Try some other name for the “fruit” class.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.