How can I make a dot notation on a function, I mean like in jQuery’s function. Example:
func("test_string").func2("test_string2");
Advertisement
Answer
You simply return an object from the first funtion which itself has a function
function func(input){ console.log("You called func with: " + input); return { func2: function(x){ console.log("You called func2 with: " + x); } } } func("test_string").func2("test_string2");