JavaScript Functions

Javascript Functions are Core part. Functions are defined with function keyword, and every function is a function object with properties and methods of the function object.

Function are not same as procedure and a function always returns the value, but the procedure may or may not return any value.
There are many ways to define the function.

function fun_name([param[, param]]) {

fun_name = Function name param = function can have 255 arguments, name of argument passed to function. Statements = consist the body of the function

String are zero index based, Starts from 0 and 1,2,3 and more. Primitive values, like (“Michel Gowna man from united states” ) can’t have properties and methods be this not object. Please check the below one to create string object.

Create String object:-

var val = new String(string);

Javascript completely depended on the below concepts:- 1) Function Declaration 2) Function Expression

Function Declaration

function declarations load before any code is executed. While function expressions loads, when the responder reaches that line of code, like declared function will not work(execute) immediately, that will be saved for particular issue, and executes later when they are called(invoked).

function myFunction(a, b) {
    return a * b;

Function Expression

Declaration and function expression are actually similar, but expression will store in variable and variable used as a function also we called this anonymous function, how we call them is exactly, but the main difference is how the browser represents them into view.

var myfun = function (x, y) {return x * y};

Javascript Constructor Function

Constructor Function name is only to define a new function, that’s reusable regular function, this is a terminology from oops (object oriented programming).

Javascript Objects-Treasure Map
var Country = function Country() {
  // ...
var country = new Country();

Explanation of constructor

When new Country() is called, some operation will happen. :- First thing is to create the object : - Second thing is to set the constructor property of the object to Country. :- Third things is It sets up the object to delegate to Country.prototype. :- Fourth thing is It calls Country() in the context of the new object. So here the result on new Country() is a new object, nothing will happened kind refreshing the object.