What is javascript function?

"function is the set of instruction. It's take input and return output based on the input."

function is the reserved key of the javascript so we can not create as name of the function. We need to create with any other name as abc or you can use Underscore(_) or use dash or Hyphen (-). But mainly we use for the naming convention with camelcase as: anyThingLearn.

When we create a function then we need to call as with parenthesis (). if we will not use () then it will return value as a objects. So always remember this thing.

Why do we use function?
We can write code one times and use again & again. also can we use more parameters.

Type of function?
1. Pre-built function as alert(), confirm().
2. Created by developer

function syntax is:

<script>
function anyThingLearn(){
var ss = "Sheo";
console.log(ss);
}
anyThingLearn(); // result will be Sheo

console.log(anyThingLearn); // result below showing
/*
Æ’ anyThingLearn(){
var ss = "Sheo";
console.log(ss);
}
*/
console.log(anyThingLearn()); // result will be Sheo
</script>



No comments:

Note: Only a member of this blog may post a comment.

Copyright Reserved to Anything Learn. Powered by Blogger.