Recently, I have been working with writing a ruby gem, Yoolk API Gem. What is really interesting for me is I do some meta programming and object-oriented programming in Ruby which I have never experienced before. A few month later, there is a requirement that my team needs to write in JavaScript, but I don’t want to touch JavaScript really much. Therefore, my team member took over this task. Whenever I write code in Ruby, I just try to think how to do it in JavaScript as well. Several things that came up to my mind with some from my team member:
Defer class from a variable
123
varklass="Person";p=newwindow[klass];//class without namespacep=newyoolk[klass];//class with namespace
123
klass="Person"p=Object.const_get(klass).new#class without namespacep=Yoolk.const_get(klass).new#class with namespace