we use javascript functions because its a basic building block of code , it help us to write a code concise , reusable and reuse it miltiple times .
function invocation means a function got executed and its not a function was called by another function and then executed .
Yes functions behave likes a objects in javascript , basically a function are known as first class object .example
function helloworld(){
console.log("tarun");
};
console.dir(helloworld);
when we console.dir we see the key value pair , objects are part of this function therefore when we do
- helloworld.length we get 0 .
- helloworld.name we get "helloworld".
- when we do helloworld.tostring it gives body of a function in "" quotes .
- we can assign a variable a value of a function
Events are basically the thimgs that happen in the system you are programming , which the system tells you about so your code can react to them .
strings in javascript are primitive data types and strings are immutable , which means the are unchanging .a javascript string is zero or more characters written inside quotes.
Array are used to store multiple values in a single variable.each item in an array has a number attached to it, called a numeric index , that allows you to access it . Arrays in javascript are dynamic because their size is not predetermined.
The main difference between set and map is that set contains only data elements , and map contains the data in the key-value pair , so map contains key and its value .
An array is a collection of items stored at contiguous memory locations . the idea is to store multiple items of the same type together whereas the map is an associative container that stores elements in a mapped fashion , each element has a key value and a mapped value . No two mapped values can have equal key values .
Array methods are functions built-in to javascript that we can apply to our arrays. some of the array methods are :
- concat()
- copywithin()
- filter()
- indexOf()
we can traverse the array by using different loops and by directly from the index of an element.