0

I didn't know that this is possible in JavaScript:

var test = {
    "hello world": function(){
       console.log('test');
    }
};

Of course this is only a theoretical question:

Is there a possible way to call the hello world function other than test["hello world"]()?
Would it be possible to call it with the . operator?

Jad Joubran
  • 2,511
  • 3
  • 31
  • 57
  • 4
    Hope you've recovered from your shocking experience, No, it would not be possible to call the function with `.`. –  Nov 10 '14 at 07:41
  • This is not a "space in a function name" It's a space in an object key. –  Nov 10 '14 at 07:45

1 Answers1

3

Sorry but if key is has some special character then you cannot call this with '.' operator.

only way to call is bracket notation which you already know

murli2308
  • 2,976
  • 4
  • 26
  • 47