Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
169
rated 0 times [  175] [ 6]  / answers: 1 / hits: 15949  / 14 Years ago, mon, august 16, 2010, 12:00:00

I have two methods with the same name, for different purposes in 2 different .js files. How can I use those methods on same page?



In Count.js:



function add()
{
// some manipulation doing here
}


In PriceImplement.js



Function add()
{
// some manipulation doing here
}

More From » javascript

 Answers
30

You should get into the habit of namespacing your JavaScript-files:



//Count.js:



var Count = {
add: function add() {
},
[additional methods in the Count object]
};


// PriceImpl.js



var Price = {
add: function add () {
},
[additional methods for the Price implementation]
};


Then call methods like Namespace.method, i.e. Price.add()


[#95903] Friday, August 13, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
austynp

Total Points: 505
Total Questions: 118
Total Answers: 106

Location: Tajikistan
Member since Sun, Aug 29, 2021
3 Years ago
austynp questions
;