Menu

Javascript granulas

One aspect of me when trying out Javascript as a new language of Fun(tm) was .. that it actually was a WTF experience. Thought that was simply my own stupidity.. But now im rather convinced that i just stumbled upon those countless strange effects of js, when writing code. Just noting an interesting read here, in case there are devs, that expereinced the same WTFs as me and are some kind frustrated when asked about "youKnowWhich". Just read following snippet and make up your mind....

function laugh()
{
  return
  {
    haha: "ha!"
  };
}
laugh();
// returns undefined

function laugh() {
  return { haha: "ha!" };
}
laugh();
// returns Object: { haha: "ha!" }

https://gist.github.com/yeco/308492

Posted by Thorsten Kani 2016-08-12

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.