Java Script
Java Script
2. Looping :- for loop, break, continue, nested for loop, while and do while loop
this loop gives values of array one by one by storing in a callback function ,more at 5.7
4. Loop in array :- For of loop => to print index value of the array
c. pop() => To remove any element from the array at end, if it is printed then it give the
removed value
d. shift() => To remove any element from the array at start, if it is printed then it give the
removed value
console.log(arr.tostring())
f. join() => Works same as tostring, we can use separators by our choice
g. includes => to check that the element is present or not in the array and give the answer in
boolean T or F
arr.splice(1,3,24)
5 Function :-
function name() {
// block of code
// block of code
here a and b are parameters for input data or other operations, we can use default parameters that
is (a, b=6), value for b is given if eternally any parameter is provided dis replaces this default
parameter
function name() {
it means it does not print any value until is store at other var and call it
5.5 this keyword:- this keyword is represent different behaviour at different places
let obj = {
name : "tanish",
course : "b.tech",
cinfo:function () {
console.log(this.name)
obj.cinfo()
let obj = {
name : "tanish",
course : "b.tech",
cinfo:() => {
console.log(this)
obj.cinfo
return res
return result(num1+num2)
console.log(outPut);
here the funntion displaydata is called in result parameter and the vlaue of result in sotred in the
displaydata function
l.foreach((v.i) => {
console.log(v,i);
})
here the elements are stored in a anonymous function (functon which has no name), the
elements are stored in first paramenter and the index value in second
This function creates new array using existing elements of previous array by performing any
operation, it creates array with same no of elements in the previous, if 5 ele in prevoius the new
will be 5
console.log(finalans)
output = [15,25,39,48,58]
return v+5
let finalans=arr.map(calculate)
console.log(finalans)
console.log(arrfilt)
console.log(final)
here the parameter totoal stores the final answer, v stores the elemets for arr and i stores idx values.
In the final variable the sum of v and i stored in the totla paramenter and after completing the
function the value of total get printed.
Example =>
console.log(head)
console.log(head.innerHTML) :- for getting inner text with innter html tags like indore under b tag
Events are things that happen in the system you are programming, which the system tells you about
so your code can react to them.
function showhidepass(){
if(btn.innerHTML=="show"){
password.type="text";
btn.innerHTML="hide";
} else {
password.type="password";
btn.innerHTML="show";