Functions are the block of code that performs specific task and often return a value. Any function can be understood as a reusable code-block that will be executed by an event, or when the function is called. A javaScript function may return zero or more parameters. Parameters can be understood as the standard technique of passing control to a function. JavaScript functions can be of two types: 1. Built-In Function: JavaScript provides a set of in built function that can be used to perform specific functions Some of them are eval(),parseInt(),parseFloat(). a. eval(): eval() function is used to convert a string expression a numeric value E.g. Evaluating a expression using eval() var a=eval(“5*5+6”); eval() function evaluates the expression and assigns 26 to variable a . Note: In case you pass a string value as a parameter eval() expression will not be generated. You need to convert the data type. This can be done using parseInt() discussed below: b. parseInt(): parseInt(
Data and Tech notes for students and professionals