0% found this document useful (0 votes)
4 views6 pages

JavaScript Functions Overview

The document discusses built-in functions in JavaScript for type conversion, including eval(), parseInt(), and parseFloat(). It explains how these functions work and the concept of passing parameters to functions and returning values. Additionally, it includes class work questions related to loops and summing numbers based on user input.

Uploaded by

Jitendra Yadav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

JavaScript Functions Overview

The document discusses built-in functions in JavaScript for type conversion, including eval(), parseInt(), and parseFloat(). It explains how these functions work and the concept of passing parameters to functions and returning values. Additionally, it includes class work questions related to loops and summing numbers based on user input.

Uploaded by

Jitendra Yadav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Functions in JavaScript

Built-in Functions
• JavaScript provides several built-in functions
that can be used to perform explicit type
conversions. Some of them are:
– eval(),
– parseInt()
– parseFloat()
Built-in Functions….
• The eval() function can be used to convert a string expression to a
numeric value
• The parseInt() function is used to convert a string value to an
integer.
• The parseInt() function returns the first integer contained in a
string or NaN(Not a number) if the string does not begin with an
integer
• The parseFloat() function is used to convert a string value to an
float.
• The parseFloat() function returns the first float contained in a
string or NaN(Not a number) if the string does not begin with an
float.
Passing Parameters to Functions
• When calling a function, some values can be
passed to the function; these values are called
arguments or parameters
Return values
• Javascript functions can return values using
return statement.
Class Work
H/W: Question 1: Why while loop is called top
tested and do…while loop is called bottom
tested?
Question 2: WAP to display the sum of even
numbers upto n where n is integer number
entered by the user
Question 3: WAP to display the sum of first
natural numbers upto n where n is the number
entered by the user

You might also like