Home Is it normal to use in the function some variable with the same name as it function?
Reply: 0

Is it normal to use in the function some variable with the same name as it function?

user541
1#
user541 Published in May 25, 2018, 8:54 am

Is it normal to use in the function some variable with the same name as it function?

const sum = function(arr) {
  let sum = 0;
  for(let i = 0; i < arr.length; i++)
    sum += arr[i]; 
  return sum;
};
This code works fine without any warnings. But I'm curious can it lead to any trouble?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.304538 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO