Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8017991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:00:11+00:00 2026-06-04T21:00:11+00:00

As part of my unit tests (using QUnit) for a backbone project, I test

  • 0

As part of my unit tests (using QUnit) for a backbone project, I test some collection manipulation functions that return arrays of backbone models.

Is there a way to directly test (for sanity’s sake) whether the objects in my array extend Backbone.Model or should I just do a duck type check (and if so, how, and on which unique attribute, for example)?

Since there is no real “Class” construct in javascript, typeof obviously won’t do the trick here.

I could see this being useful in other tests down the road for my Collections, or to check that things are instances of my specific Backbone classes, etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:00:13+00:00Added an answer on June 4, 2026 at 9:00 pm

    How about using instanceof:

    console.log(yourObject instanceof Backbone.Model);
    

    The instanceof operator tests whether an object has in its prototype
    chain the prototype property of a constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PHPUnit to try to unit test some PHP files that are part
I am using silverlight unit tests to test an important part of our site.
We have some scripts that we run as part of our unit tests. This
It has been decided to write some unit tests using moq etc..It's lots of
I've created a unit test that tests interactions on my ViewModel class in a
I've been using MSTest so far for my unit-tests, and found that it would
I have a class that I made for some unit tests. Everything was going
I believe strongly in using unit-tests as part of building large multi-platform applications. We
For unit testing you shouldn't test private methods, yes, but for integration tests (using
I have some unit tests that use Azure Storage. When running these locally, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.