Javascript Class Instance - 3/12


#1

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


#2

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


#3

yes …sorry wait…


#4
class Surgeon {
  constructor(name, department) {
    this.name = name;
    this.department = department;
  }
}

const surgeonCurry = new name('Curry');
console.log(surgeonCurry.name);

#5

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');

#6

wait …i will try and tell


#7

you don’t have to tell me you are going to try, i assume you would. Just report back with the results


#8

i got it bro …
it went well…
thank you very much::grinning:


#9