To install the package run: npm install jsgetfirst --save
To get it in you project, call it in you file and use it directly.
//Calling jsgetfirst package
const {getfirst} = require('jsgetfirst');
//Calling jsgetfirst package
const {getfirst} = require('jsgetfirst');
//Array to get first item
const arrayList = ["50", "25", "100"];
//Use getfirst in your code
const getFirstExample = () => {
return getfirst(arrayList);
}
In the previous example you will get "50" as a result of getFirstExample call.
Proceed as the above example:
//Calling jsgetfirst package
const {getfirst} = require('jsgetfirst');
//Object to get first item
const testObject = {
car : {
wheels : 4,
doors : 3,
power: 25
},
truk : {
wheels : 12,
doors : 2,
power: 125
},
bus : {
wheels : 12,
doors : 5,
power: 100
}
}
//Use getfirst in your code
const getFirstExample = () => {
return getfirst(testObject);
}
Here the result obtined will be:
{
car: {
wheels: 4,
doors: 3,
power: 25
}
}