Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138163

func.func1 is not a function how to use funcition from function?

$
0
0

function foo(a) {
  console.log(a);
  return a;
}

const fooSpy = spy(foo);

fooSpy('test'); // return: test
fooSpy.callCount(); // out: 1
fooSpy.calledWith('test'); // out: true
fooSpy.calledWith('test123'); // out: false
fooSpy.returned('test'); // out: true


function spy(func) {
  let fooSpy = {
    callCount: function() {
      console.log('testss')
    }
  }
  console.log(func);
  if (func === undefined) {
    console.log(1);
  }
  spy.prototype.callCount = function() {
    console.log('win')
  };
  return func;
}
fooSpy.prototype.callCount = function() {
  console.log('win')
};

I have an error fooSpy.callCount is not a function
How can I use fooSpy.callCount? How to use a function that is inside another and access it from the outside? or maybe there is another way to solve this task? https://jsfiddle.net/qbvsu7rt/23/ there is u can try to check the console


Viewing all articles
Browse latest Browse all 138163

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>