I've created a class "BFSPlayer" in Javascript with a constructor, and inside this constructor I've defined a function(which is not executed) named "myFunction". Then I've created an object "obj" of BFSPlayer class and then I want to run that myFunction for this object. Here's how I'm trying to do it, but it's not working:
class BFSPlayer {
constructor(args){
var player;
function myFunction(){
player = {
videoId: args
}
}
}
}
var obj=new BFSPlayer('video-id');
obj.constructor.myFunction();
Any help would be thankful to me
myFunction()is private to the constructor function. It is not a property of the constructed object and it is not a property of the constructor function itself. It is no more available outside the constructor than the variable "player" is.