1
var DOM_N$ = function(selector){
    this.selector = selector;
    return "jello world";
}
DOM_N$.prototype = {
    getSelector: function(){
        return this.selector;
    }
}
function N$(selector){
    return (new DOM_N$(selector));
}

N$('element').selector; //wont return selector because of return
N$('element'); //returns element

I am trying to return the values from an object when no other methods are being called but my return is interrupting my objects methods.

7
  • No, you cannot return both. Commented Aug 18, 2015 at 20:55
  • But i want to, & Jquery does it. Commented Aug 18, 2015 at 20:56
  • in jquery $('element'); will return and has methods to call with it Commented Aug 18, 2015 at 20:57
  • No, jQuery doesn't do it. jQuery does always return a collection of elements. I really don't get what you want this return this.nodes; to do. Just omit it. Commented Aug 18, 2015 at 20:58
  • 1
    i think it will help if you'll provide us with an "expected result vs actual result" Commented Aug 18, 2015 at 21:01

1 Answer 1

1

For DOM_N$ be a constructor, it should returns nothing

var DOM_N$ = function(selector){
    this.selector = selector;
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.