150 likes | 236 Views
This presentation on JavaScript functions covers all the basics that you need understand what are functions in JavaScript, how to create functions in JavaScript, JavaScript functions expressions, function constructor, what are self-invoking functions, functions as values, functions as object, what are array functions, generator functions and pre-defined functions. <br><br>This JavaScript Certification course helps you master the JavaScript programming language in an all-inclusive training program that includes complete JavaScript fundamentals, jQuery, Ajax, and more. You will apply your skills by building a real-time chat application.<br><br>JavaScript Course Overview:<br>This training program entails the fundamentals of JavaScript, including the enumeration and elaboration of various data types in JavaScript, an explanation of loops and conditional statements in JavaScript, and an overview of the concepts of objects and variables in JavaScript.<br><br>JavaScript Certification Key Features<br>1. 100% Money Back Guarantee<br>2. 7 complete JavaScript courses<br>3. Covers Ajax, jQuery, and node.js<br>4. Build a real-time chat application<br>5. Course completion certificate<br><br>ud83dudc49Learn more at: https://bit.ly/2SDfYlR
E N D
What’s in it for you? What are JavaScript functions? Function expressions Function() constructor Self-invoking functions Functions as values Functions as objects Arrow functions Generator function Predefined functions
What are JavaScript functions? A function is a group of reusable code which can be called anywhere in your program This eliminates the need of writing the same code again and again It helps programmers write modular codes
Function Expression A JavaScript function can also be defined using an expression A function expression can be stored in a variable:
The Function Constructor JavaScript functions are defined using the keyword function. Functions can also be defined using the built-in JavaScript function constructor called Function()
Self-Invoking functions A self-invoking expression is invoked (started) automatically, without being called Function expressions will execute automatically if the expression is followed by () You have to add parentheses around the function to indicate that it is a function expression
Functions as values In JavaScript, a function is a value, so we can deal with it as a value. We first define the function and then assign it to a variable unlike in expressions
Functions as objects JavaScript functions are a special type of objects, called function objects A function object includes a string which holds the actual code i.e., the function body of the function
Arrow functions Functions can be written more compactly with the help of Arrow functions Arrow function expressions are ill suited as methods, and they cannot be used as constructors The above code can be re-written like this
To create a generator, we need a special syntax construct: function*, so-called “generator function” Generator functions Regular functions return only one, single value (or nothing) Generators can return (“yield”) multiple values, one after another, on-demand To create a generator, we use the syntax: function*
To create a generator, we need a special syntax construct: function*, so-called “generator function” Generator functions Regular functions return only one, single value (or nothing) Generators can return (“yield”) multiple values, one after another, on-demand To create a generator, we use the syntax: function* next() returns two properties: value: The yielded value done: True if the function code is finished, false if otherwise
To create a generator, we need a special syntax construct: function*, so-called “generator function” Predefined functions eval Evaluates a string and returns a value parseInt Parses a string argument and returns an integer of the specified radix or base parseFloat Parses a string argument and returns a floating-point number escape Returns the hexadecimal encoding of an argument unescape Returns the ASCII string for the specified value