help me …why am i getting this error…
/home/ccuser/workspace/learn-javascript-classes-classes-instance/main.js:8
const surgeonCurry = new name(‘Curry’);
^
ReferenceError: name is not defined
at Object. (/home/ccuser/workspace/learn-javascript-classes-classes-instance/main.js:8:26)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
at bootstrap_node.js:542:3
thank you
we talked about this in earlier topic, if you don’t include your full code, its nearly impossible to tell what is causing the error
2 Likes
class Surgeon {
constructor(name, department) {
this.name = name;
this.department = department;
}
}
const surgeonCurry = new name('Curry');
console.log(surgeonCurry.name);
1 Like
here:
const surgeonCurry = new name('Curry');
why use new name
? You want to create a new instance of Surgeon
the general syntax is:
const instance = new Class('possible arguments');
3 Likes
wait …i will try and tell
1 Like
you don’t have to tell me you are going to try, i assume you would. Just report back with the results
2 Likes
i got it bro …
it went well…
thank you very much:
1 Like