如何调用此函数内部的函数?
var video = function() {
this.name = "Name of Video";
this.desc = "Short Description of Video";
this.long = "Long Description of Video";
function metadata(){
return {
name : this.name,
shortDescription : this.desc,
longDescription : this.long
};
};
};
Run Code Online (Sandbox Code Playgroud)
使它成为新对象的方法:
var video = function() {
this.name = "Name of Video";
this.desc = "Short Description of Video";
this.long = "Long Description of Video";
this.metadata = function(){
return {
name : this.name,
shortDescription : this.desc,
longDescription : this.long
};
};
};
var videoObject = new video();
videoObject.metadata();
Run Code Online (Sandbox Code Playgroud)
除了所述功能之外,你不能.
var video = function() {
this.name = "Name of Video";
this.desc = "Short Description of Video";
this.long = "Long Description of Video";
function metadata(){
return {
name : this.name,
shortDescription : this.desc,
longDescription : this.long
};
};
metadata();
};
Run Code Online (Sandbox Code Playgroud)