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

  • Home
  • SEARCH
  • 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 9242595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:36:45+00:00 2026-06-18T08:36:45+00:00

I have the following simple CoffeeScript Class: class Country constructor: (@val) -> console.log @val

  • 0

I have the following simple CoffeeScript Class:

class Country
    constructor: (@val) ->
        console.log @val
    foreign: ->
        @val isnt "United States"
    domestic: ->
        not foreign()

I have this simple class to determine some logic for a select drop down.

Here is how I am calling it:

$country = new Country($val) if $('select[id*="country"]').val() > 0
console.log $country.foreign? if $country?

$val is being set in an on('change') event. $country.foreign? is always evaluating to true even if I select a country other than the US. Not sure what I am doing wrong here. The @val is being set to the value I am passing in, but the foreign function isn’t working properly

  • 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-18T08:36:46+00:00Added an answer on June 18, 2026 at 8:36 am

    It should be

    console.log $country.foreign()? if $country?
    

    foreign is a function call.

    Also that translates to this:

    if (typeof $country !== "undefined" && $country !== null) {
      console.log($country.foreign() != null);
    }
    

    So you get a log of whether or not the return is null, you probably want to drop the ?

    console.log $country.foreign() if $country?
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following simple class: @interface Article: NSObject { NSString *title; } @property (copy,
I have the following simple class definition: //mycommon.h @interface CurrentPath : NSObject @property (nonatomic,
I have following two simple POJOs: class Person { String name Address address; //and
I have the following simple class class base { public: int x; base &set(int
I have the following simple constructor: public SimpleClass(Type1 arg1, int interval = 1000) {
I have the following (simple) mapping: @Entity public class Role { @OneToMany( fetch =
I have the following simple Threaded fileserver to be used by my application: class
I have the following (simple) CoffeeScript jQuery Plugin: $ = jQuery $.fn.extend schoolSelect: (options)
I have the following (extremely simple) module definition, in CoffeeScript: # backbone/routers/appointments_router.js.coffee define [app,
I have following simple page: public class Login extends BasePage { private UserDao userDao;

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.