How to gain access to the instances of a class?

Latest challenge is that I have an object person and an array attribute for Loves, meaning an array of also persons who a person cares for. However my addtoLoves method doesn’t check to verify if any string giberish i want to add to a person’s love list is actually a person. How do i access the instances of a class so I can verify that a person can have only legit other person objects in their list of people they care about?

I’m not a JS Guru but AFAIK JS is not a strongly typed language.
I.e. you don’t have int, string, object, you name it.
You have const, var and let. Then the interpreter infers the type.

I would look toward instanceOf or typeOf to try determine the object you’re dealing with.

Also you can check if what is passed to your function has a property simply by giving its dot notation. If it exists the result is truthy.

function addToLoves(lover){
    if( // Do something if lover has a name.

Hope this helps.

I tried the concept… this is similar but i’m trying to use authentication credentials, once successful to locate the person object that is associated… i have much more info about people at the object layer (that i don’t want to persist in a db), so after authentication i have to find the person that just logged in… so i tried this:

export const RequestHandler = function RequestHandler (ServiceRequest) {

let Fname = ServiceRequest.FirstName;
let Lname = ServiceRequest.LastName;
let userEmail = ServiceRequest.userID;
let city =;
let intent = ServiceRequest.intent;


if (Fname == Person.FirstName) {
console.log (‘person object found’);

It is not giving me an error, but it’s not finding the person object that matches the login credentials either…


In the line

if (Fname == Person.FirstName) {

What is Person? Is that defined above?

it’s an object class that represents a person and holds attributes about the person.


i solved this by creating a collection for people and making my own people creation method that creates “new” persons but also adds them to the collection at the same time. PEOPLE is the one global i will need to maintain.