+ 1
Colon or equal?
In first snippet, should = be used instead of : ? Or can they be used interchangeably?
4 Answers
+ 2
Edited
The snippet is correct. But the examples do not illustrate it's usage(it's done in previous lesson examples)
let f = {
myMethod: function(){ //colon syntax
return "From inside my method"
}
}
console.log(f.myMethod())
//not the best example bht works...check the lesson code for a better demo.
function f(){
this.met = function(){// equals syntax
return "from inside method_new"
}
}
console.log(new f().met())
lesson: https://www.sololearn.com/learn/JavaScript/1154/
+ 1
Which language are you talking about?
+ 1
thanks it is clear now
0
i am referring to snippet âmethodName : function() { code lines }â in javascript course under title adding methods