+ 1

Colon or equal?

In first snippet, should = be used instead of : ? Or can they be used interchangeably?

8th Apr 2019, 7:03 PM
Azhar Ul Islam 🇵🇰
Azhar Ul Islam 🇵🇰 - avatar
4 ответов
+ 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/
9th Apr 2019, 12:02 AM
Lord Krishna
Lord Krishna - avatar
+ 1
Which language are you talking about?
8th Apr 2019, 7:08 PM
Nahuel Ourthe
Nahuel Ourthe - avatar
+ 1
thanks it is clear now
9th Apr 2019, 4:38 AM
Azhar Ul Islam 🇵🇰
Azhar Ul Islam 🇵🇰 - avatar
0
i am referring to snippet “methodName : function() { code lines }” in javascript course under title adding methods
8th Apr 2019, 7:39 PM
Azhar Ul Islam 🇵🇰
Azhar Ul Islam 🇵🇰 - avatar