SlideShare a Scribd company logo
Javascript function
 Specifies the number of arguments
expected by the function.
 Syntax
› functionName.length
 console.log( (function () {}).length );
 console.log( (function (a) {}).length );
 console.log( (function (a, b) {}).length );
 function ArgTest(a, b){
 var s = "";
 s += "Expected Arguments: " + ArgTest.length;
 s += "<br />";
 s += "Passed Arguments: " + arguments.length;
 return s;
 }
 Calls a function with a given this value and
arguments provided individually.
 Syntax
› fun.call(thisArg[, arg1[, arg2[, ...]]])
 function diplayInfo(year, month, day){
 return "Name:" + this.name + ";birthday:" + year +
"." + month + "." + day;
 }
 var p = { name: "Jason" };
 diplayInfo.call(p, 1985, 11, 5);
 Calls a function with a given this value
and arguments provided as an array
 Syntax
› fun.apply(thisArg[, argsArray])
 function diplayInfo(year, month, day){
 return "Name:" + this.name + ";birthday:" + year +
 "." + month + "." + day;
 }
 var p = { name: "Jason" };
 console.log(diplayInfo.apply(p, [1985, 11, 5]));
 Specifies the currently executing function
 callee is a property of the arguments object.
 Syntax
› [function.]arguments.callee
 function factorial(n){
 if (n <= 0)
 return 1;
 else
 return n * arguments.callee(n - 1);
 }
 factorial(4);
 Creates a new function that, when
called, has its this keyword set to the
provided value, with a given sequence
of arguments preceding any provided
when the new function is called.
 Syntax
fun.bind(thisArg[, arg1[, arg2[, ...]]])
 var x = 9;
 var module = {
 x: 81,
 getX: function() { return this.x; }
 };
 module.getX(); //Answer: ?
 var getX = module.getX;
 getX(); //Answer: ?
 var boundGetX = getX.bind(module);
 boundGetX(); //Answer: ?
 module.x = 100;
 boundGetX(); //Answer: ?
 var checkNumericRange = function (value) {
 return value >= this.min && value <= this.max;
 }
 var range = { min: 10, max: 20 };
 var boundCheckNumericRange =
checkNumericRange.bind(range);
 var result = boundCheckNumericRange (12);
 Result = ??
 var displayArgs = function (val1, val2, val3, val4) {
 console.log(val1 + " " + val2 + " " + val3 + " " +
val4);
 }
 var emptyObject = {};
 var displayArgs2 =
displayArgs.bind(emptyObject, 12, "a");
 displayArgs2("b", "c"); //Answer: ?
 Javascript MDN
› https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Reference/Global_Obj
ects/Function
 Javascript MSDN
› http://teamserver:8080/tfs/DefaultCollection/!Ba
cklog/_boards

More Related Content

PPTX
Javascript Function
PPT
JavaScript Functions
PPTX
This pointer
PPTX
LinkedIn TBC JavaScript 100: Functions
PPTX
c++ pointers by Amir Hamza Khan (SZABISTIAN)
PPT
Function
PPTX
Pointer to function 2
PPT
Unit 6 pointers
Javascript Function
JavaScript Functions
This pointer
LinkedIn TBC JavaScript 100: Functions
c++ pointers by Amir Hamza Khan (SZABISTIAN)
Function
Pointer to function 2
Unit 6 pointers

What's hot (20)

PPTX
Java script
PPTX
Pointers in C/C++ Programming
PPT
PPTX
Pointer to function 1
PPTX
Function Pointer
PPT
Function overloading(C++)
PDF
JavaScript Functions
PDF
Python Functions (PyAtl Beginners Night)
PPTX
C++ Pointers
PPTX
Command line arguments
PPTX
Pointers in c++
PPTX
Variadic functions
PPTX
functions of C++
PDF
Functions in python
PDF
삼성 바다 앱개발 실패 노하우 2부
DOCX
Maharishi University of Management (MSc Computer Science test questions)
PDF
Extend GraphQL with directives
DOCX
Arrry structure Stacks in data structure
PPTX
Recursion in c++
PPTX
Python Programming Essentials - M17 - Functions
Java script
Pointers in C/C++ Programming
Pointer to function 1
Function Pointer
Function overloading(C++)
JavaScript Functions
Python Functions (PyAtl Beginners Night)
C++ Pointers
Command line arguments
Pointers in c++
Variadic functions
functions of C++
Functions in python
삼성 바다 앱개발 실패 노하우 2부
Maharishi University of Management (MSc Computer Science test questions)
Extend GraphQL with directives
Arrry structure Stacks in data structure
Recursion in c++
Python Programming Essentials - M17 - Functions
Ad

Similar to Javascript function (20)

PPT
25-functions.ppt
PDF
JavaScript - Chapter 6 - Basic Functions
PPTX
11. session 11 functions and objects
PPTX
Functional Programming in Javascript - IL Tech Talks week
PPT
JavaScript Functions
PPTX
The JavaScript Programming Language
PDF
Functional programming java
PPTX
An Introduction to Functional Programming with Javascript
PDF
Introduction to Functional Programming (w/ JS)
PPS
CS101- Introduction to Computing- Lecture 29
PPTX
ECMA5 and ES6 Promises
PPSX
Javascript variables and datatypes
PDF
java script functions, classes
PPTX
Java script functions
PDF
Functional Javascript, CVjs
PPTX
predefined and user defined functions
PDF
TI1220 Lecture 6: First-class Functions
KEY
Functional programming in clojure
PPTX
Lecture 4- Javascript Function presentation
PDF
Rediscovering JavaScript: The Language Behind The Libraries
25-functions.ppt
JavaScript - Chapter 6 - Basic Functions
11. session 11 functions and objects
Functional Programming in Javascript - IL Tech Talks week
JavaScript Functions
The JavaScript Programming Language
Functional programming java
An Introduction to Functional Programming with Javascript
Introduction to Functional Programming (w/ JS)
CS101- Introduction to Computing- Lecture 29
ECMA5 and ES6 Promises
Javascript variables and datatypes
java script functions, classes
Java script functions
Functional Javascript, CVjs
predefined and user defined functions
TI1220 Lecture 6: First-class Functions
Functional programming in clojure
Lecture 4- Javascript Function presentation
Rediscovering JavaScript: The Language Behind The Libraries
Ad

More from LearningTech (20)

PPTX
PPTX
PostCss
PPTX
ReactJs
PPTX
Docker
PPTX
Semantic ui
PPTX
node.js errors
PPTX
Process control nodejs
PPTX
Expression tree
PPTX
SQL 效能調校
PPTX
flexbox report
PPTX
Vic weekly learning_20160504
PPTX
Reflection &amp; activator
PPTX
Peggy markdown
PPTX
Node child process
PPTX
20160415ken.lee
PPTX
Peggy elasticsearch應用
PPTX
Expression tree
PPTX
Vic weekly learning_20160325
PPTX
D3js learning tips
PPTX
git command
PostCss
ReactJs
Docker
Semantic ui
node.js errors
Process control nodejs
Expression tree
SQL 效能調校
flexbox report
Vic weekly learning_20160504
Reflection &amp; activator
Peggy markdown
Node child process
20160415ken.lee
Peggy elasticsearch應用
Expression tree
Vic weekly learning_20160325
D3js learning tips
git command

Recently uploaded (20)

PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Machine learning based COVID-19 study performance prediction
PDF
KodekX | Application Modernization Development
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Approach and Philosophy of On baking technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Modernizing your data center with Dell and AMD
PDF
cuic standard and advanced reporting.pdf
PPTX
Cloud computing and distributed systems.
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Network Security Unit 5.pdf for BCA BBA.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Machine learning based COVID-19 study performance prediction
KodekX | Application Modernization Development
Understanding_Digital_Forensics_Presentation.pptx
NewMind AI Weekly Chronicles - August'25 Week I
The AUB Centre for AI in Media Proposal.docx
Approach and Philosophy of On baking technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Modernizing your data center with Dell and AMD
cuic standard and advanced reporting.pdf
Cloud computing and distributed systems.
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Reach Out and Touch Someone: Haptics and Empathic Computing
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Bridging biosciences and deep learning for revolutionary discoveries: a compr...

Javascript function

  • 2.  Specifies the number of arguments expected by the function.  Syntax › functionName.length
  • 3.  console.log( (function () {}).length );  console.log( (function (a) {}).length );  console.log( (function (a, b) {}).length );
  • 4.  function ArgTest(a, b){  var s = "";  s += "Expected Arguments: " + ArgTest.length;  s += "<br />";  s += "Passed Arguments: " + arguments.length;  return s;  }
  • 5.  Calls a function with a given this value and arguments provided individually.  Syntax › fun.call(thisArg[, arg1[, arg2[, ...]]])
  • 6.  function diplayInfo(year, month, day){  return "Name:" + this.name + ";birthday:" + year + "." + month + "." + day;  }  var p = { name: "Jason" };  diplayInfo.call(p, 1985, 11, 5);
  • 7.  Calls a function with a given this value and arguments provided as an array  Syntax › fun.apply(thisArg[, argsArray])
  • 8.  function diplayInfo(year, month, day){  return "Name:" + this.name + ";birthday:" + year +  "." + month + "." + day;  }  var p = { name: "Jason" };  console.log(diplayInfo.apply(p, [1985, 11, 5]));
  • 9.  Specifies the currently executing function  callee is a property of the arguments object.  Syntax › [function.]arguments.callee
  • 10.  function factorial(n){  if (n <= 0)  return 1;  else  return n * arguments.callee(n - 1);  }  factorial(4);
  • 11.  Creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called.  Syntax fun.bind(thisArg[, arg1[, arg2[, ...]]])
  • 12.  var x = 9;  var module = {  x: 81,  getX: function() { return this.x; }  };  module.getX(); //Answer: ?  var getX = module.getX;  getX(); //Answer: ?  var boundGetX = getX.bind(module);  boundGetX(); //Answer: ?  module.x = 100;  boundGetX(); //Answer: ?
  • 13.  var checkNumericRange = function (value) {  return value >= this.min && value <= this.max;  }  var range = { min: 10, max: 20 };  var boundCheckNumericRange = checkNumericRange.bind(range);  var result = boundCheckNumericRange (12);  Result = ??
  • 14.  var displayArgs = function (val1, val2, val3, val4) {  console.log(val1 + " " + val2 + " " + val3 + " " + val4);  }  var emptyObject = {};  var displayArgs2 = displayArgs.bind(emptyObject, 12, "a");  displayArgs2("b", "c"); //Answer: ?
  • 15.  Javascript MDN › https://developer.mozilla.org/en- US/docs/Web/JavaScript/Reference/Global_Obj ects/Function  Javascript MSDN › http://teamserver:8080/tfs/DefaultCollection/!Ba cklog/_boards