Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Arguments in JavaScript
WhatsApp
Kaushik S
Nov 23
2015
996
0
0
Example 1:
Simple function without arguments.
Example 2:
A function with 1 parameter and how to access using argument.
Example 3:
A function with 2 parameter and how to access using argument.
Example 4:
A function with 2 parameter and to find the number of parameters.
Example 5:
To access parameters with for loop.
Example 6:
Displays the contents and the output of the function.
Example 7:
To know the type of document.
<html>
<head >
<title></title>
</head>
<body>
<form id=
"form1"
>
<div>
</div>
</form>
<script type=
"text/javascript"
>
function
Example1(arg)
{
document.write(
"Example1 :"
+ arg);
}
Example1(
"Sachin Tendulkar"
)
function
Example2(arg) {
document.write(
" Example2 :"
+ Example2.arguments[0]);
}
Example2(
"Sachin Tendulkar "
)
function
Example3(arg1,arg2) {
document.write(
" Example3 :"
+ Example3.arguments[0] +
" and "
+ Example3.arguments[1]+
" are great"
);
}
Example3(
"Sachin Tendulkar"
,
"Saurav Ganguly"
);
function
Example4(arg1, arg2) {
document.write(
"Length:"
+arguments.length);
}
Example4(
"Sachin Tendulkar"
,
"Saurav Ganguly"
)
function
Example5() {
document.write(
"Length:"
+ arguments.length);
}
Example5(
"Sachin Tendulkar"
,
"Saurav Ganguly"
)
function
Example6() {
for
(
var
i = 0; i < arguments.length;i++) {
document.write(arguments[i]+
" "
);
}
}
Example6(
"Sachin Tendulkar"
,
"Saurav Ganguly"
)
function
Example7() {
document.write(
":"
+ arguments[0]);
document.write(
":"
+ arguments[1]);
}
Example7(
"Sachin Tendulkar"
,
"Saurav Ganguly"
);
function
Example8() {
arguments[0]=
"Kaushik"
;
document.write(
":"
+ arguments[0]);
document.write(
":"
+ arguments[1]);
}
Example8(
"Sachin Tendulkar"
,
"Saurav Ganguly"
);
function
Example9()
{
var
sum = 0;
for
(
var
i = 0; i < 5; i++) {
sum = sum + i;
}
document.write(
"output: "
+sum+
" :"
);
document.write(arguments.callee);
}
Example9();
function
Example10() {
document.write(
typeof
arguments)
}
Example10();
</script>
</body>
</html>
Arguments
Arguments in JavaScript
JavaScript
Up Next
Arguments in JavaScript