Child pages
  • Function

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{hidden}
DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY, UNLESS YOU KNOW WHAT YOU'RE DOING.
		THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO EXTRACT CHANGES FROM THE PAGE AND MERGE THEM BACK INTO SERVOY SOURCE{hidden}
{sub-section:description|text=}{sub-section}\\

{table:id=|class=servoy sSummary}{colgroup}{column:padding=0px|width=80px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Property Summary{th}{tr}{tbody}{tr}{td}[Function]{td}{td}[#constructor]
Specifies the function that creates an object's prototype.{td}{tr}{tbody}{tbody}{tr}{td}[Number]{td}{td}[#length]
Specifies the number of arguments expected by the function.{td}{tr}{tbody}{table}\\

{table:id=|class=servoy sSummary}{colgroup}{column:padding=0px|width=80px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Method Summary{th}{tr}{tbody}{tr}{td}void{td}{td}[#apply]()
Applies the method of another object in the context of a different object (the calling object); arguments can be passed as an Array object.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#bind]()
Creates a new function which, when called, itself calls this function in the context of the provided value, with a given sequence of arguments preceding any provided when the new function was called.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#call]()
Calls (executes) a method of another object in the context of a different object (the calling object); arguments can be passed as they are.{td}{tr}{tbody}{tbody}{tr}{td}[String]{td}{td}[#toString]()
Returns a string representing the source code of the function.{td}{tr}{tbody}{table}\\

{table:id=property|class=servoy sDetail}{colgroup}{column:padding=0px|width=100%}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Property Details{th}{tr}{tbody:id=constructor|class=node}{tr:id=name}{td}
h6. constructor{td}{tr}{tr:id=des}{td}{sub-section:constructor_des|text=|trigger=button}{sub-section}{sub-section:constructor_des|trigger=none|class=sIndent}Specifies the function that creates an object's prototype.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:constructor_snc|text=|trigger=button}{sub-section}{sub-section:constructor_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:constructor_prs|text=|trigger=button}{sub-section}{sub-section:constructor_prs|trigger=none|class=sIndent}{sub-section}{td}{tr}{builder-show{td}{tr}{tr:id=ret}{td}{*}Returns*
\\ [Function]{td}{tr}{tr:id=retsee}{td}{*}ReturnsAlso see*
\\ {sub-section:constructor_ret|text=|trigger=button}{sub-section}{sub-section:constructor_ret|trigger=none|class=sIndent}[Function]{sub-sectiondiv:class=sIndent}{div}{td}{tr}{builder-show:permission=edit}{tr:id=seelink}{td}*AlsoExternal seelinks*\\{sub-section:constructor_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:constructor_see|trigger=none}{sub-section}{div:class=sIndent}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=linksam}{td}{*}Sample*External
links*\\ {sub-section:constructor_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:constructor_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}{*}Sample*
\\ {sub-section:constructor_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:constructor_sam|trigger=none}{code:language=javascript}
function Tree(name) {
	this.name = name;
}
theTree = new Tree("Redwood");
application.output("theTree.constructor is " + theTree.constructor);
{code}{sub-section}{div}{div:class=sIndent}{code:language=javascript}
function Tree(name) {
	this.name = name;
}
theTree = new Tree("Redwood");
application.output("theTree.constructor is " + theTree.constructor);
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=length|class=node}{tr:id=name}{td}
h6. length{td}{tr}{tr:id=des}{td}Specifies the number of arguments expected by the function.{td}{tr}{tr:classid=lastDetailRowsnc}{td}*Since*\\ Replace with version info{td}{tr}{tbody}{tbody:id=length|class=nodetr:id=prs}{td}*Parameters*\\{td}{tr}{tr:id=nameret}{td}
h6. length{*}Returns*
\\ [Number]{td}{tr}{tr:id=dessee}{td}{sub-section:length_des|text=|trigger=button}{sub-section}{sub-section:length_des|trigger=none|class=sIndent}Specifies the number of arguments expected by the function.{sub-section*Also see*\\{div:class=sIndent}{div}{td}{tr}{tr:id=link}{td}*External links*\\{div:class=sIndent}{div}{td}{tr}{builder-show:permission=edit}{tr:id=sncsam}{td}{*Since}Sample*
\\ {sub-section:length_snc|text=|trigger=button}{sub-section}{sub-section:length_snc|trigger=none|class=sIndent} Replace with version info{sub-sectiondiv:class=sIndent}{code:language=javascript}
function addNumbers(x, y){
	if (addNumbers.length == 2) {
		return (x + y);
	} else
		return 0;
}
{code}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:length_prs|text=|trigger=button}{sub-section}{sub-section:length_prs|trigger=none|class=sIndent}{sub-section}{td}{tr}{builder-show}{tr:id=ret}{td}{*}Returns*
\\ {sub-section:length_ret|text=|trigger=button}{sub-section}{sub-section:length_ret|trigger=none|class=sIndent}[Number]{sub-section}{td}{tr}{builder-show:permission=edittr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}\\

{table:id=function|class=servoy sDetail}{colgroup}{column:padding=0px|width=100%}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=apply|class=node}{tr:id=name}{td}
h6. apply{td}{tr}{tr:id=seesig}{td}*Also see*\\{sub-section:length_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:length_see|trigger=none}{sub-section}{div}{{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}apply{span}{span:id=iets|style=float: left;}(){span}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=linkdes}{td}*External links*\\{sub-section:length_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:length_link|trigger=none}{sub-section}{div}{td}{tr}{builder-showApplies the method of another object in the context of a different object (the calling object); arguments can be passed as an Array object.{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\{td}{tr}{tr:id=samret}{td}{*}SampleReturns*
\\ {sub-section:length_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:length_sam|trigger=none}{code:language=javascript}
function addNumbers(x, y){
	if (addNumbers.length == 2) {
		return (x + y);
	} else
		return 0;
}
{code}{sub-section}{void{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{td}{tr}{tr:id=link}{td}*External links*\\{div:class=sIndent}{div}{td}{tr}{tr:classid=lastDetailRowsam}{td}{td}{tr}{tbody}{table}*}Sample*
\\
 {tablediv:id=function|class=servoy sDetail}{colgroup}{column:padding=0px|width=100%}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=apply|class=node}{tr:id=name}{td}
h6. apply{td}{tr}{tr:id=sig}{td}{span:style=class=sIndent}{code:language=javascript}
function book(name, author) {
	this.name = name;
	this.author = author;
}

function book_with_topic(name, author, topic) {
	this.topic = topic;
	book.apply(this, arguments);
}
book_with_topic.prototype = new book();

var aBook = new book_with_topic("name","author","topic");
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=bind|class=node}{tr:id=name}{td}
h6. bind{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}applybind{span}{span:id=iets|style=float: left;}(){span}{td}{tr}{tr:id=des}{td}{sub-section:apply_des|text=|trigger=button}{sub-section}{sub-section:apply_des|trigger=none|class=sIndent}Applies the method of another objectCreates a new function which, when called, itself calls this function in the context of athe differentprovided objectvalue, (thewith callinga object);given arguments can be passed as an Array object.{sub-section}{sequence of arguments preceding any provided when the new function was called.{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:apply_snc|text=|trigger=button}{sub-section}{sub-section:apply_snc|trigger=none|class=sIndent} Replace with version info{sub-section} Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\{td}{tr}{builder-show}{builder-show:permission=edittr:id=ret}{td}{*}Returns*
\\ void{td}{tr}{tr:id=prssee}{td}*ParametersAlso see*\\{sub-section:apply_prs|text=|trigger=button}{sub-section}{sub-section:apply_prs|trigger=none|div:class=sIndent}{div}{td}{tr}{tr:id=link}{td}*External links*\\{div:class=sIndent}{sub-sectiondiv}{td}{tr}{builder-show}{tr:id=retsam}{td}{*}ReturnsSample*
\\ {sub-section:apply_ret|text=|trigger=button}{sub-section}{sub-section:apply_ret|trigger=none|div:class=sIndent}void{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:apply_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:apply_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:apply_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:apply_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}{*}Sample*
\\ {sub-section:apply_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:apply_sam|trigger=none}{code:language=javascript}
function book(name, author) {
	this.name = name;
	this.author = author;
}

function book_with_topic(name, author, topic) {
	this.topic = topic;
	book.apply(this, arguments);
}
book_with_topic.prototype = new book();

var aBook = new book_with_topic("name","author","topic");
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=bind|class=node}{tr:id=name}{td}
h6. bind{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}bind{span}{span:id=iets|style=float: left;}(){span}{td}{tr}{tr:id=des}{td}{sub-section:bind_des|text=|trigger=button}{sub-section}{sub-section:bind_des|trigger=none|class=sIndent}Creates a new function which, when called, itself calls this function in the context of the provided value, with a given sequence of arguments preceding any provided when the new function was called.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:bind_snc|text=|trigger=button}{sub-section}{sub-section:bind_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:bind_prs|text=|trigger=button}{sub-section}{sub-section:bind_prs|trigger=none|class=sIndent}{sub-section}{td}{tr}{builder-show}{tr:id=ret}{td}{*}Returns*
\\ {sub-section:bind_ret|text=|trigger=button}{sub-section}{sub-section:bind_ret|trigger=none|class=sIndent}void{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:bind_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:bind_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:bind_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:bind_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}{*}Sample*
\\ {sub-section:bind_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:bind_sam|trigger=none}{code:language=javascript}
var x = 9,
	module = {
		getX: function() {
		     return this.x;
		},
		x: 81
	};
//  "module.getX()" called, "module" is "this", "module.x" is returned
module.getX(); // > 81
//  "getX()" called, "this" is global, "x" is returned
getX(); // > 9
//  store a reference with "module" bound as "this"
var boundGetX = getX.bind(module);
//  "boundGetX()" called, "module" is "this" again, "module.x" is returned
boundGetX(); // > 81
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=call|class=node}{tr:id=name}{td}
h6. call{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}call{span}{span:id=iets|style=float: left;}(){span}{td}{tr}{tr:id=des}{td}{sub-section:call_des|text=|trigger=button}{sub-section}{sub-section:call_des|trigger=none|class=sIndent}Calls (executes) a method of another object in the context of a different object (the calling object); arguments can be passed as they are.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:call_snc|text=|trigger=button}{sub-section}{sub-section:call_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:call_prs|text=|trigger=button}{sub-section}{sub-section:call_prs|trigger=none|class=sIndent}{sub-section}{td}{tr}{builder-show}{tr:id=ret}{td}{*}Returns*
\\ {sub-section:call_ret|text=|trigger=button}{sub-section}{sub-section:call_ret|trigger=none|class=sIndent}void{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:call_see|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:call_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:call_link|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:call_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}{*}Sample*
\\ {sub-section:call_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:call_sam|trigger=none}{code:language=javascript}
function book(name) {
	this.name = name;
}

function book_with_author(name, author) {
	this.author = author;
	book.call(this, name);
}
book_with_author.prototype = new book();

var aBook = new book_with_author("name","author");
{code}{sub-section}{div}{code:language=javascript}
var x = 9,
	module = {
		getX: function() {
		     return this.x;
		},
		x: 81
	};
//  "module.getX()" called, "module" is "this", "module.x" is returned
module.getX(); // > 81
//  "getX()" called, "this" is global, "x" is returned
getX(); // > 9
//  store a reference with "module" bound as "this"
var boundGetX = getX.bind(module);
//  "boundGetX()" called, "module" is "this" again, "module.x" is returned
boundGetX(); // > 81
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=call|class=node}{tr:id=name}{td}
h6. call{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}call{span}{span:id=iets|style=float: left;}(){span}{td}{tr}{tr:id=des}{td}Calls (executes) a method of another object in the context of a different object (the calling object); arguments can be passed as they are.{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\{td}{tr}{tr:classid=lastDetailRowret}{td}{*}Returns*
\\ void{td}{tr}{tbody}{tbodytr:id=toString|class=node}{tr:id=name}{td}
h6. toStringsee}{td}*Also see*\\{div:class=sIndent}{div}{td}{tr}{tr:id=siglink}{td}{span:style=float: left; margin-right: 5px;}[String]{span}{span:id=iets|style=float: left; font-weight: bold;}toString{span}{span:id=iets|style=float: left;}(){span*External links*\\{div:class=sIndent}{div}{td}{tr}{tr:id=dessam}{td}{sub-section:toString_des|text=|trigger=button}{sub-section}{sub-section:toString_des|trigger=none|class=sIndent}Returns a string representing the source code of the function. Overrides the Object.toString method.{sub-section*}Sample*
\\ {div:class=sIndent}{code:language=javascript}
function book(name) {
	this.name = name;
}

function book_with_author(name, author) {
	this.author = author;
	book.call(this, name);
}
book_with_author.prototype = new book();

var aBook = new book_with_author("name","author");
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{builder-show:permission=edittbody}{tbody:id=toString|class=node}{tr:id=name}{td}
h6. toString{td}{tr}{tr:id=sncsig}{td}*Since*\\{sub-section:toString_snc|text=|trigger=button}{sub-section}{sub-section:toString_snc|trigger=none|class=sIndent} Replace with version info{sub-section{span:style=float: left; margin-right: 5px;}[String]{span}{span:id=iets|style=float: left; font-weight: bold;}toString{span}{span:id=iets|style=float: left;}(){span}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=prsdes}{td}*Parameters*\\{sub-section:toString_prs|text=|trigger=button}{sub-section}{sub-section:toString_prs|trigger=none|class=sIndent}{sub-section}{td}{tr}{builder-showReturns a string representing the source code of the function. Overrides the Object.toString method.{td}{tr}{tr:id=retsnc}{td}{*}ReturnsSince*
\\ Replace {sub-section:toString_ret|text=|trigger=button}{sub-section}{sub-section:toString_ret|trigger=none|class=sIndent}[String]{sub-section}with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\{td}{tr}{builder-show:permission=edit}{tr:id=seeret}{td}{*}Returns*Also
see*\\{sub-section:toString_see|text=|trigger=button}{sub-section} [String]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{sub-section:toString_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:toString_link|text=|trigger=button}{sub-section}\\{div:class=sIndent}{sub-section:toString_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}{*}Sample*
\\ {sub-section:toString_sam|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:toString_sam|trigger=none}{code:language=javascript}
function printHello() {
		return "Hello";
}
application.output(printHello.toString());
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}