{"action":"created","issue":{"url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4237","repository_url":"https://api.github.com/repos/jashkenas/coffeescript","labels_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4237/labels{/name}","comments_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4237/comments","events_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4237/events","html_url":"https://github.com/jashkenas/coffeescript/issues/4237","id":143920193,"number":4237,"title":"Private variables in coffeescript (not duplicate)","user":{"login":"MegaJsTeam","id":17149958,"avatar_url":"https://avatars.githubusercontent.com/u/17149958?v=3","gravatar_id":"","url":"https://api.github.com/users/MegaJsTeam","html_url":"https://github.com/MegaJsTeam","followers_url":"https://api.github.com/users/MegaJsTeam/followers","following_url":"https://api.github.com/users/MegaJsTeam/following{/other_user}","gists_url":"https://api.github.com/users/MegaJsTeam/gists{/gist_id}","starred_url":"https://api.github.com/users/MegaJsTeam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MegaJsTeam/subscriptions","organizations_url":"https://api.github.com/users/MegaJsTeam/orgs","repos_url":"https://api.github.com/users/MegaJsTeam/repos","events_url":"https://api.github.com/users/MegaJsTeam/events{/privacy}","received_events_url":"https://api.github.com/users/MegaJsTeam/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-28T07:48:13Z","updated_at":"2016-04-02T21:29:53Z","closed_at":null,"body":"```coffeescript\r\nclass Cat\r\n\r\n  constructor: ->\r\n    @..name = 11\r\n    return\r\n\r\n\r\n  ..func: -> 1+1\r\n\r\n\r\n(new Cat).name  #undefined\r\n(new Cat)['..name']  #undefined\r\n ```\r\ncompile to:\r\n\r\n```javascript\r\n\r\nvar Cat (function(){\r\n\r\n  var _private_name_ = Symbol('name');\r\n  var _private_func_ = Symbol('func');\r\n\r\n  function Cat(){\r\n      this[_private_name_] = 11\r\n  }\r\n\r\n  Cat.prototype[_private_func_] = function(){ return 1+1 }\r\n\r\n  return Cat;\r\n\r\n});\r\n\r\n\r\n(new Cat).name  //undefined\r\n ```\r\n\r\nand Symbol polyfilled like:\r\n\r\n```javascript\r\n_crateSymbol = function(name){  \r\n   return window.Symbol ? Symbol(name) : Math.random().toString().slice(2)+name\r\n }\r\n```\r\n   \r\nthere props not available in the child classes, since only the current class has access to the variable _private_name_. in the Symbol polyfill conflict names prevented by Math.random().\r\n\r\n\r\np.s. yes, people can access to private props from outside like this obj['23424235254name'] , but they don't do that, cuz not wants break theirs program."},"comment":{"url":"https://api.github.com/repos/jashkenas/coffeescript/issues/comments/204807372","html_url":"https://github.com/jashkenas/coffeescript/issues/4237#issuecomment-204807372","issue_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4237","id":204807372,"user":{"login":"MegaJsTeam","id":17149958,"avatar_url":"https://avatars.githubusercontent.com/u/17149958?v=3","gravatar_id":"","url":"https://api.github.com/users/MegaJsTeam","html_url":"https://github.com/MegaJsTeam","followers_url":"https://api.github.com/users/MegaJsTeam/followers","following_url":"https://api.github.com/users/MegaJsTeam/following{/other_user}","gists_url":"https://api.github.com/users/MegaJsTeam/gists{/gist_id}","starred_url":"https://api.github.com/users/MegaJsTeam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MegaJsTeam/subscriptions","organizations_url":"https://api.github.com/users/MegaJsTeam/orgs","repos_url":"https://api.github.com/users/MegaJsTeam/repos","events_url":"https://api.github.com/users/MegaJsTeam/events{/privacy}","received_events_url":"https://api.github.com/users/MegaJsTeam/received_events","type":"User","site_admin":false},"created_at":"2016-04-02T21:29:53Z","updated_at":"2016-04-02T21:29:53Z","body":"this is cool syntax \r\n"}}