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 8791473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:50:52+00:00 2026-06-13T22:50:52+00:00

I have several div with the same album class, so I wanted to create

  • 0

I have several div with the same “album” class, so I wanted to create a class using constructor and prototype. Here’s what I did

function Album(album){
    this.album = album;

    console.log(this.album === album)
    console.log($(this.album) === $(album))
}

Album.prototype = {
    init: function(){

    },

    loadImages: function(){

    }
};

$('.album').each(function(){    
    var album = new Album(this);
});

I need to access the album variable that I passed in to the class Album in the init function, so I have to store it in this.album. However I don’t understand that why
console.log(this.album === album) is true but
console.log($(this.album) === $(album)) is false

I need to use jquery in prototype, is there other way to do so? Thanks.

  • 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-13T22:50:52+00:00Added an answer on June 13, 2026 at 10:50 pm
    $('body') === $('body') // false
    

    Basically, you are doing this right. jQuery is screwing with you.

    With objects the === operator is only true if it is the same object. In this case, jQuery makes a brand new object each time it wraps a DOM element, making a new object even if it’s wrapping the same element it did a second ago.

    Here’s an example of why this is in plain JS, without jQuery:

    var domEl = document.getElementById('whatev');
    var a = { el: domEl };
    var b = { el: domEl };
    
    domEl === domEl // true
    a === b         // false
    

    Here there is 2 objects, both have identical data and wrap the same object. But they are different objects and therefore not === to each other.

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

Sidebar

Related Questions

I have several divs like this <div rel=5> Divs content goes here </div> <div
I have several blocks that look like this: <div class='templatechoicedesigncss'> <img src='/images/templatepics/random(100x140).png' /> <p>
I have html that looks like this with several items <div class=item> <p class=price>$388.00</p>
In jQuery, I'm creating several div elements within a class: function class([..]) { this.par1
I have several contact forms using the same general AJAX code: $(document).ready(function() { $('#mainMail').submit(
I have a page containing several divs with the same class name for CSS
I have a div container which have several images,like this: <div style=width:600px;height:600px;> <img src=
I have several fixed position divs with the same class at varying distances from
I have a string which contains several different prices. This is the string: <div
I have several sections of markup in a report that look like this: <div

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.