Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Named Object Property Functions

Tags:

javascript

render: function render(context, partials) {
  return this.r(context, partials);
},

Given this code from Twitter's new hogan.js library to demonstrate the issue; what is the goal of naming the function twice?

like image 304
Gavin Schulz Avatar asked Dec 22 '11 17:12

Gavin Schulz


1 Answers

If it wanted to, the function render would be able to call itself via render(), however, render() is not accessible anywhere else.

Additionally, in a stack trace, you'd see render as the function name, rather than anonymous function.

like image 109
Matt Avatar answered Oct 15 '22 05:10

Matt