Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

An Array Of Functions


	const fns = [()=>{console.log("first")}, ()=>{console.log("second")}, function(){console.log("third")}]

fns[0]();
/*remember the (), the function will not execute with only fns[0]*/
Comment

array of

Array.of(7);       // [7]
Array.of(1, 2, 3); // [1, 2, 3]

Array(7);          // [ , , , , , , ]
Array(1, 2, 3);    // [1, 2, 3]
Comment

array of function

#include <iostream>

using namespace std;

class fish
{
public:
    fish();
    int getAge() {return age;}
    void setAge(int newage) { age = newage; }
private:
    int age;
};

fish::fish()
{
    age = 0;
}

void showAges(fish fishes[])
{
    cout << "fish 1 age is: " << fishes[0].getAge() << endl;
    cout << "fish 2 age is: " << fishes[1].getAge() << endl;
    cout << "fish 3 age is: " << fishes[2].getAge() << endl;
}

int main()
{
    fish myFish[3];

    showAges(myFish);
    cout << endl;

    myFish[0].setAge(10);
    myFish[1].setAge(20);
    myFish[2].setAge(30);

    showAges(myFish);

    cin.get();
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: koa get post body 
Javascript :: wakatime cli installation via npm 
Javascript :: check trigger is human jquery 
Javascript :: js decrypt online 
Javascript :: how can i add + buttons for expand and - button for collapse in react 
Javascript :: navigating to another screen from the react native navigation header 
Javascript :: applicature 
Javascript :: playwrigth await browser 
Javascript :: Yup validation for objects and object shape 
Javascript :: recharts area chart 
Javascript :: joi for validation 
Javascript :: HimalayanCoffeeHouse Noida 
Javascript :: joi validation error message in path parameter value array to string 
Javascript :: js set utils 
Javascript :: javascript float not showing 0 
Javascript :: "date change error" 
Javascript :: Reverse string by using split () method to convert our string into an array 
Javascript :: show route between markers google maps javascript 
Javascript :: ajax:drop-down remove an d add select option 
Javascript :: find a node that match a spesific selector string in the paren 
Javascript :: react native red Half Circle bubble 
Javascript :: tailwind intenseness react 
Javascript :: react native delay input 
Javascript :: netlify not deploying react site 
Javascript :: ajax slick slidre 
Javascript :: react 5 to 10 rating 
Javascript :: loop through table print in javascript 
Javascript :: how to bind two ng-content in a component angular 
Javascript :: GET / - - ms - - node js 
Javascript :: caeser psypher javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =