Hi,
I have a method in common property, and I want to use it in a home page property, but I don’t want to re-create the method?
I tried with a test method and is return test is not a function:
var MySite = {
// All pages
'common': {
init: function() {
var test = function(i) {
return i;
}
test();
},
// Home page
'home': {
init: function() {
console.table(MySite.common.init.test('call'));
},
}
}
console.table(SmileCare.common.init.test('ddd'));
You have a scope problem - you can’t access test because it’s a local variable inside your MySite.common.init() function.
It’s hard to know exactly what you’re trying to do without more information but you could always add your test function to the common object. For example:
Comment tu sais que je suis français?
Je suis en train d’apprendre React, je vais suivre cette formation, c’est frustrant parce que je pensait être bon avec js.
D’ailleurs j’ai obtenu le frontend certificate, FCC et c’est pas facile a obtenir