0% found this document useful (0 votes)
5 views6 pages

JS

The document contains JavaScript code snippets demonstrating various functions and operations such as multiplication, object creation, array mapping, filtering, reducing, sorting, and iteration. It showcases different ways to define functions, manipulate arrays, and access object properties. The code examples illustrate fundamental programming concepts in JavaScript.

Uploaded by

ajdcyhzvp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

JS

The document contains JavaScript code snippets demonstrating various functions and operations such as multiplication, object creation, array mapping, filtering, reducing, sorting, and iteration. It showcases different ways to define functions, manipulate arrays, and access object properties. The code examples illustrate fundamental programming concepts in JavaScript.

Uploaded by

ajdcyhzvp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Function

function myFunction(p1, p2) {


return p1 * p2;
}

let myFunction = function (p1, p2) {


return p1 * p2;
}

let myFunction = (p1, p2) => {


return p1 * p2;
}
String

let obj = {
"count1" : "india",
"count2" : 8,
"count3" : "japan",
"count4" : (t) => {
return t+1;
}
}
[Link](obj.count2);
let arr = [1,2,3,4,5,6,7,8,9,10];
arr = [Link]((number,index) => {
[Link](index);
return number*number;
})
[Link](arr);

let arr = [1,2,3,4,5,6,7,8,9,10];


arr = [Link]((val) =>{
return val % 2 == 0
})
[Link](arr)

let arr = [10,20,30,40];

let ans = [Link]((acc,val) => {return acc+val},0);


[Link](ans)

let arr = [4,1,7,4,8,3]


[Link]()
[Link](arr)
[Link]()
[Link](arr)
let arr = [4,1,7,4,8,3]
[Link]([Link](4))

let obj = {
name : "Shreyash",
age : 21,
degree: "BTech",
gender: "Male"
}
for(let key in obj){
[Link](key+" = "+obj[key]);
}

[Link]([Link]);

let arr = [1,2,3,4,5]


for(let key of arr){
[Link](key);
}

You might also like