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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:56:09+00:00 2026-05-26T02:56:09+00:00

This coffee script code class TestCoffee constructor: (@saludo) -> helloCoffee: -> alert @saludo+ Coffee

  • 0

This coffee script code

    class TestCoffee
        constructor: (@saludo) ->

    helloCoffee: ->
        alert @saludo+" Coffee v7"

is generating the following javascript with mindscape web workbench 2.0.332.18684

    (function() {
        var TestCoffee;
        TestCoffee = (function() {
          function TestCoffee(saludo) {
            this.saludo = saludo;
          }
          TestCoffee.prototype.helloCoffee = function() {
            return alert(this.saludo + " Coffee v7");
          };
          return TestCoffee;
        })();
    }).call(this);

How should I use this code inside my asp.net mvc 3 view?

I’m importing the js code with

<script src="@Url.Content("~/Scripts/helloCoffe.js")" type="text/javascript"></script>

and trying to use with

    <script type="text/javascript">

    $(document).ready(function () {

        var coffee;

        coffee = TestCoffee("Jelouuuu");

        coffee.helloCoffee();

    });

</script>

I got a TestCoffee undefined error

So, how should I use it?

Thanks In Advance!

  • 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-05-26T02:56:10+00:00Added an answer on May 26, 2026 at 2:56 am

    This is by design:

    Although suppressed within this documentation for clarity, all
    CoffeeScript output is wrapped in an anonymous function: (function(){
    … })(); This safety wrapper, combined with the automatic generation
    of the var keyword, make it exceedingly difficult to pollute the
    global namespace by accident.

    If you’d like to create top-level variables for other scripts to use,
    attach them as properties on window, or on the exports object in
    CommonJS. The existential operator (covered below), gives you a
    reliable way to figure out where to add them; if you’re targeting both
    CommonJS and the browser: exports ? this

    http://jashkenas.github.com/coffee-script/

    I normally use jQuery $.extend to push a function into the jquery namespace for other scripts to use.

    IE:

    file1.coffee

    $ ->
        $.extend
            ErrorAlert: (text) ->
                simpleGritter $("#SuccessGritter"), text
                return false
    

    file2.coffee

    $ ->
        $("#right").ajaxError (event, request, settings) ->
            $.ErrorAlert("Some kind of bad thing happened at: " + settings.url)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following coffeescript code: class Animal constructor: (@name) -> speak: (things) -> My
I have the following code inside a class. (It's coffeescript-- and it's for a
I'm trying to convert a function from Javascript to CoffeeScript. This is the code:
Looking at this CoffeeScript tutorial : http://jashkenas.github.com/coffee-script/ I don't quite see what the Splats
This probably has a simple answer, but I must not have had enough coffee
In Brad's CorePlot I've seen this snippet, which eliminated the need for some coffee.
what is wrong in this code? when i change drop down list,the grid takes
Maybe I need more coffee this morning but here goes... I have a very
I overheard this at a coffee table conversation and i wasnt able to fathom
No coffee. Brain. Not. Functioning. I have this linq query here: Public Function ListAllVisitDates()

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.