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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:43:04+00:00 2026-06-17T23:43:04+00:00

// util/model.js define([‘util/class’], function(classCtor) { return classCtor.create({ set: function(key, value) { // this doesn’t

  • 0
// util/model.js

define(['util/class'], function(classCtor) {
    return classCtor.create({
        set: function(key, value) {
            // this doesn't work, because self is pointing to window
            if (value instanceof self) {
                // do Something
            }
        }
    });
});

This should be the base class of all my entitys. Because my modules are written in RequireJS style, i’m able to use the following workaround:

if (value instanceof require('util/model'))

This works fine, but now my code is coupled to the ModuleName. Any suggestions how to avoid this coupling?
By the way: I use the prototype-based helper from Steffen Rusitschka to build my classes

  • 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-17T23:43:05+00:00Added an answer on June 17, 2026 at 11:43 pm

    You could just use a variable for your anonymous class:

    define(['util/class'], function(classCtor) {
        var self = classCtor.create({
            set: function(key, value) {
                // self is the class now:
                if (value instanceof self) {
                    // do Something
                }
            }
        });
        return self;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Student.java package Model; import java.util.Set; public class Student { private int studentID; private String
I am using a model in Play like this: package models; import java.util.*; import
I have following java class package com.picvik.model; import java.util.Date; public class ViewAlbum { private
I am trying to create a class say MyStack that would implement a java.util.collections
How to compare java.util.Date value with String using JSTL and EL? This is the
Where do you put non-controller, non-model code, like util classes, extension methods and so
java.util.concurrent.ConcurrentLinkedQueue comes to mind, but is it really optimum for this two-thread scenario? I
When using java.util.logging, the log level for a specific class (i.e. for a child
import java.util.Scanner; public class CourseSplitter { public static void main(String args[]){ Scanner keyboard =
I have a static util class that does some string manipulation on a bit

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.