Untitled
unknown
plain_text
a year ago
1.9 kB
8
Indexable
// splice
// slice
// last index of
// index of
// splice method
// parameters (1st - position start , 2nd - how many element should be replace , 3rd - this element will be added as the new element)
// const arr = [1, 2, 3, 4, 5, 6, 7, 8];
// arr.splice(3, 2, 33, 23);
// console.log(arr)
// slice method
// create another array by giving the new array
// slice(1st - starting index , 2nd - end index)
// const arr1 = [1, 2, 3, 4, 5, 6, 7, 8];
// const a = arr1.slice(0, 3);
// console.log(arr1);
// console.log(a);
// index of - find the first index of duplicates element of
// indexing start from 0,1,2,3,4.......
// const arr1 = [1, 2, 3, 4, 5, 6, 7, 8];
// const a = arr1.indexOf(4);
// console.log(a)
// last index of - find the last index of duplicates function
// const arr1 = [1, 2, 3, 4, 5, 6, 7, 5, 8 , 5];
// const a = arr1.indexOf(5);
// const b = arr1.lastIndexOf(5);
// console.log(a)
// console.log(b)
// callback function
// passing a function as an argument to the another function and calling this from that another function
// function hello() {
// console.log("hello")
// }
// function greet(x) {
// console.log("welcome");
// x();
// }
// greet(hello)
// higher order function
// that function which takes function as an argument or return function from it are called higher order function
// in this case function greet is taking hello function as an argument , so it is a higher order function
// function hello() {
// console.log("hello")
// }
// function greet(x) {
// console.log("welcome");
// x();
// }
// greet(hello)
// function hii() {
// return 45456;
// console.log("first")
// }
// function hii() {
// return function () {
// return function () {
// return function () {
// console.log("function inside function");
// }
// }
// }
// }
// const a = hii();
// const b = a();
// const c = b();
// c()
Editor is loading...
Leave a Comment